jawa.attribute module

jawa.attribute.ATTRIBUTE_CLASSES = {'BootstrapMethods': <class 'jawa.attributes.bootstrap.BootstrapMethodsAttribute'>, 'Code': <class 'jawa.attributes.code.CodeAttribute'>, 'ConstantValue': <class 'jawa.attributes.constant_value.ConstantValueAttribute'>, 'Deprecated': <class 'jawa.attributes.deprecated.DeprecatedAttribute'>, 'EnclosingMethod': <class 'jawa.attributes.enclosing_method.EnclosingMethodAttribute'>, 'Exceptions': <class 'jawa.attributes.exceptions.ExceptionsAttribute'>, 'InnerClasses': <class 'jawa.attributes.inner_classes.InnerClassesAttribute'>, 'LineNumberTable': <class 'jawa.attributes.line_number_table.LineNumberTableAttribute'>, 'LocalVariableTable': <class 'jawa.attributes.local_variable.LocalVariableTableAttribute'>, 'LocalVariableTypeTable': <class 'jawa.attributes.local_variable_type.LocalVariableTypeTableAttribute'>, 'Signature': <class 'jawa.attributes.signature.SignatureAttribute'>, 'SourceFile': <class 'jawa.attributes.source_file.SourceFileAttribute'>, 'StackMapTable': <class 'jawa.attributes.stack_map_table.StackMapTableAttribute'>, 'Synthetic': <class 'jawa.attributes.synthetic.SyntheticAttribute'>}

A dictionary of known attribute subclasses at the time this module was loaded.

class jawa.attribute.Attribute(parent: jawa.attribute.AttributeTable, name_index: int)[source]

Bases: object

ADDED_IN = None
MINIMUM_CLASS_VERSION = None
cf

The ClassFile that owns this attribute, if any.

name

The name of this attribute.

pack() → bytes[source]

This attribute packed into its on-disk representation.

unpack(info: Union[bytes, jawa.util.stream.BufferStreamReader])[source]

Parses an instance of this attribute from the blob info.

class jawa.attribute.AttributeTable(cf, parent: jawa.attribute.Attribute = None)[source]

Bases: object

cf = None

The ClassFile that ultimately owns this AttributeTable.

create(type_, *args, **kwargs) → Any[source]

Creates a new attribute of type_, appending it to the attribute table and returning it.

find(*, name: str = None, f: Callable = None) → Iterator[Any][source]
find_one(**kwargs) → Any[source]

Same as find() but returns only the first result.

pack(out: IO)[source]

Write the AttributeTable to the file-like object out.

Note

Advanced usage only. You will typically never need to call this method as it will be called for you when saving a ClassFile.

Parameters:out – Any file-like object providing write()
parent = None

The parent Attribute, if one exists.

unpack(source: IO)[source]

Read the ConstantPool from the file-like object source.

Note

Advanced usage only. You will typically never need to call this method as it will be called for you when loading a ClassFile.

Parameters:source – Any file-like object providing read()
class jawa.attribute.UnknownAttribute(parent: jawa.attribute.AttributeTable, name_index: int)[source]

Bases: jawa.attribute.Attribute

pack() → bytes[source]

This attribute packed into its on-disk representation.

unpack(info: Union[bytes, jawa.util.stream.BufferStreamReader])[source]

Parses an instance of this attribute from the blob info.

jawa.attribute.get_attribute_classes() → Dict[str, jawa.attribute.Attribute][source]

Lookup all builtin Attribute subclasses, load them, and return a dict