public class AttributeInfo extends AbstractStructureWithAttributes
Modifier and Type | Field and Description |
---|---|
static String |
SYSTEM_PROPERTY_SKIP_ATTRIBUTES
Set this JVM System property to true to skip reading of all attributes.
|
attributes
classFile, debug, SYSTEM_PROPERTY_DEBUG
Modifier | Constructor and Description |
---|---|
protected |
AttributeInfo()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static AttributeInfo |
createOrSkip(DataInput in,
ClassFile classFile)
Factory method for creating AttributeInfo structures.
|
int |
getAttributeLength()
Get the length of this attribute as a number of bytes.
|
int |
getAttributeNameIndex()
Get the constant pool index for the name of the attribute.
|
byte[] |
getInfo()
Get the raw bytes of the attribute.
|
String |
getName()
Get the name of the attribute.
|
protected String |
printAccessFlagsVerbose(int accessFlags)
Utility method for derived structures.
|
void |
read(DataInput in)
Read this structure from the given DataInput.
|
void |
setAttributeNameIndex(int attributeNameIndex)
Set the constant pool index for the name of the attribute.
|
void |
setInfo(byte[] info)
Set the raw bytes of the attribute.
|
void |
write(DataOutput out)
Write this structure to the given DataOutput.
|
findAttribute, getAttributes, getTotalAttributesLength, readAttributes, setAttributes, writeAttributes
debug, getClassFile, getDebug, getLength, printAccessFlags, printAccessFlagsVerbose, printBytes, setClassFile, setDebug
public static final String SYSTEM_PROPERTY_SKIP_ATTRIBUTES
public static AttributeInfo createOrSkip(DataInput in, ClassFile classFile) throws InvalidByteCodeException, IOException
An AttributeInfo of the appropriate subtype from the attributes package is created unless the type of the attribute is unknown in which case an instance of AttributeInfo is returned.
Attributes are skipped if the environment variable SYSTEM_PROPERTY_SKIP_ATTRIBUTES is set to true.
in
- the DataInput from which to read the AttributeInfo structureclassFile
- the parent class file of the structure to be createdInvalidByteCodeException
- if the byte code is invalidIOException
- if an exception occurs with the DataInputpublic int getAttributeNameIndex()
public void setAttributeNameIndex(int attributeNameIndex)
attributeNameIndex
- the new indexpublic byte[] getInfo()
Is non-null only if attribute is of unknown type.
public void setInfo(byte[] info)
Works only if attribute is an instance of AttributeInfo.
info
- the new byte arraypublic String getName() throws InvalidByteCodeException
InvalidByteCodeException
- if the byte code is invalidpublic void read(DataInput in) throws InvalidByteCodeException, IOException
AbstractStructure
Excpects DataInput to be in JVM class file format and just before a structure of this kind. No look ahead parsing since the class file format is deterministic.
read
in class AbstractStructure
in
- the DataInput from which to readInvalidByteCodeException
- if the byte code is invalidIOException
- if an exception occurs with the DataInputpublic void write(DataOutput out) throws InvalidByteCodeException, IOException
AbstractStructure
The written bytes are in JVM class file format.
write
in class AbstractStructure
out
- the DataOutput to which to writeInvalidByteCodeException
- if the structure is internally inconsistentIOException
- if an exception occurs with the DataOutputpublic int getAttributeLength()
protected String printAccessFlagsVerbose(int accessFlags)
AbstractStructure
printAccessFlagsVerbose
in class AbstractStructure
accessFlags
- the unsigned short value to print as a hex string