public class CodeAttribute extends AttributeInfo
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTE_NAME
Name of the attribute as in the corresponding constant pool entry.
|
SYSTEM_PROPERTY_SKIP_ATTRIBUTES
attributes
classFile, debug, SYSTEM_PROPERTY_DEBUG
Constructor and Description |
---|
CodeAttribute() |
Modifier and Type | Method and Description |
---|---|
protected void |
debug(String message)
Utility method for derived structures.
|
int |
getAttributeLength()
Get the length of this attribute as a number of bytes.
|
byte[] |
getCode()
Get the code of this code attribute as an array of bytes .
|
ExceptionTableEntry[] |
getExceptionTable()
Get the exception table of this code attribute as an array of
ExceptionTableEntry elements.
|
int |
getMaxLocals()
Get the maximum number of local variables of this code attribute.
|
int |
getMaxStack()
Get the maximum stack depth of this code attribute.
|
void |
read(DataInput in)
Read this structure from the given DataInput.
|
void |
setCode(byte[] code)
Set the code of this code attribute as an array of bytes .
|
void |
setExceptionTable(ExceptionTableEntry[] exceptionTable)
Set the exception table of this code attribute as an array of
ExceptionTableEntry elements.
|
void |
setMaxLocals(int maxLocals)
Set the maximum number of local variables of this code attribute.
|
void |
setMaxStack(int maxStack)
Set the maximum stack depth of this code attribute.
|
void |
write(DataOutput out)
Write this structure to the given DataOutput.
|
createOrSkip, getAttributeNameIndex, getInfo, getName, printAccessFlagsVerbose, setAttributeNameIndex, setInfo
findAttribute, getAttributes, getTotalAttributesLength, readAttributes, setAttributes, writeAttributes
getClassFile, getDebug, getLength, printAccessFlags, printAccessFlagsVerbose, printBytes, setClassFile, setDebug
public static final String ATTRIBUTE_NAME
public int getMaxStack()
public void setMaxStack(int maxStack)
maxStack
- the stack depthpublic int getMaxLocals()
public void setMaxLocals(int maxLocals)
maxLocals
- the maximum numberpublic byte[] getCode()
public void setCode(byte[] code)
code
- the arraypublic ExceptionTableEntry[] getExceptionTable()
public void setExceptionTable(ExceptionTableEntry[] exceptionTable)
exceptionTable
- the arraypublic 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 AttributeInfo
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 AttributeInfo
out
- the DataOutput to which to writeInvalidByteCodeException
- if the structure is internally inconsistentIOException
- if an exception occurs with the DataOutputpublic int getAttributeLength()
AttributeInfo
getAttributeLength
in class AttributeInfo
protected void debug(String message)
AbstractStructure
debug
in class AbstractStructure
message
- the debug message