public final class CodeAttribute_info extends Attribute_info
Method_info structures. A Code attribute
contains the JVM instructions and auxiliary information for a single Java method,
instance initialization method, or class or interface initialization method.
Every Java Virtual Machine implementation must recognize Code attributes. There
must be exactly one Code attribute in each method_info structure.The Code attribute has the format
Code_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 max_stack;
u2 max_locals;
u4 code_length;
u1 code[code_length];
u2 exception_table_length;
{ u2 start_pc;
u2 end_pc;
u2 handler_pc;
u2 catch_type;
} exception_table[exception_table_length];
u2 attributes_count;
attribute_info attributes[attributes_count];
}
The value of the max_stack item gives the maximum number of words on the operand
stack at any point during execution of this method.The value of the max_locals item gives the number of local variables used by this method, including the parameters passed to the method on invocation. The index of the first local variable is 0 . The greatest local variable index for a one-word value is max_locals-1 . The greatest local variable index for a two-word value is max_locals-2.
The value of the code_length item gives the number of bytes in the code array for this method. The value of code_length must be greater than zero; the code array must not be empty.The code array gives the actual bytes of Java Virtual Machine code that implement the method.
The value of the exception_table_length item gives the number of entries in the
exception_table table. Each entry in the exception_table array describes one
exception handler in the code array: see Exception_info.
The value of the attributes_count item indicates the number of attributes of the Code attribute. Each value of the attributes table must be a variable-length attribute structure. A Code attribute can have any number of optional attributes associated with it.
| 限定符和类型 | 字段和说明 |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
int |
m_max_locals |
int |
m_max_stack |
ATTRIBUTE_BRIDGE, ATTRIBUTE_CODE, ATTRIBUTE_CONSTANT_VALUE, ATTRIBUTE_EXCEPTIONS, ATTRIBUTE_INNERCLASSES, ATTRIBUTE_LINE_NUMBER_TABLE, ATTRIBUTE_SOURCEFILE, ATTRIBUTE_SYNTHETIC, m_attribute_length, m_name_index| 构造器和说明 |
|---|
CodeAttribute_info(int attribute_name_index,
int max_stack,
int max_locals,
byte[] code,
IExceptionHandlerTable exceptionHandlerTable,
IAttributeCollection attributes) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
accept(IAttributeVisitor visitor,
Object ctx) |
Object |
clone()
Performs a deep copy.
|
IAttributeCollection |
getAttributes() |
byte[] |
getCode()
NOTE: must also use getCodeSize()
|
int |
getCodeSize() |
IExceptionHandlerTable |
getExceptionTable() |
long |
length()
Returns the total length of this attribute when converted to
.class format [including the 6-byte header]
|
void |
setCode(byte[] code,
int codeSize) |
String |
toString() |
void |
writeInClassFormat(UDataOutputStream out) |
getName, new_Attribute_infopublic static final byte[] EMPTY_BYTE_ARRAY
public int m_max_stack
public int m_max_locals
public CodeAttribute_info(int attribute_name_index,
int max_stack,
int max_locals,
byte[] code,
IExceptionHandlerTable exceptionHandlerTable,
IAttributeCollection attributes)
public final byte[] getCode()
public final int getCodeSize()
public IAttributeCollection getAttributes()
public IExceptionHandlerTable getExceptionTable()
public long length()
Attribute_infolength 在类中 Attribute_infopublic void accept(IAttributeVisitor visitor, Object ctx)
accept 在类中 Attribute_infopublic String toString()
toString 在类中 Attribute_infopublic Object clone()
clone 在类中 Attribute_infopublic void writeInClassFormat(UDataOutputStream out) throws IOException
writeInClassFormat 在接口中 IClassFormatOutputwriteInClassFormat 在类中 Attribute_infoIOExceptionpublic void setCode(byte[] code,
int codeSize)
Copyright © 2018. All rights reserved.