The Code attribute is a variable-length attribute used in the attributes
table of {@link com.vladium.jcd.cls.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 {@link 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. |