TheGenericAttribute_info {
u2 attribute_name;
u4 attribute_length;
u1 info[attribute_length];
}
attribute_name
is a 16-bit index into the class's constant pool; the value of constant_pool[attribute_name]
is a CONSTANT_Utf8
string giving the name of the attribute. The field attribute_length
indicates the length of the subsequent information in bytes. This length does not include the six bytes of the attribute_name
and attribute_length
.In the following text, whenever we allow attributes, we give the name of the attributes that are currently understood. In the future, more attributes will be added. Class file readers are expected to skip over and ignore the information in any attribute they do not understand.
SourceFile_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 sourcefile_index;
}
constant_pool[attribute_name_index]
is the CONSTANT_Utf8
string "SourceFile
".
constant_pool[sourcefile_index]
is a CONSTANT_Utf8
string giving the source file from which this class file was compiled.
ConstantValue_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 constantvalue_index;
}
constant_pool[attribute_name_index]
is the CONSTANT_Utf8
string "ConstantValue
".
constant_pool[constantvalue_index]
gives the constant value for this field. The constant pool entry must be of a type appropriate to the field, as shown by the following table:
long | CONSTANT_Long |
float | CONSTANT_Float |
double | CONSTANT_Double |
int, short, char, byte, boolean | CONSTANT_Integer |
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[attribute_count];
}
constant_pool[attribute_name_index]
is the CONSTANT_Utf8
string "Code
".
tableswitch
and tablelookup
opcode entries will be aligned; see their description for more information on alignment requirements.
start_pc
and end_pc
indicate the ranges in the code at which the exception handler is active. The values of both fields are offsets from the start of the code. start_pc
is inclusive. end_pc
is exclusive.
catch_type
is nonzero, then constant_pool[catch_type]
will be the class of exceptions that this exception handler is designated to catch. This exception handler should only be called if the thrown exception is an instance of the given class.If catch_type is zero, this exception handler should be called for all exceptions.
Exceptions_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 number_of_exceptions;
u2 exception_index_table[number_of_exceptions];
}
constant_pool[attribute_name_index]
will be the CONSTANT_Utf8
string "Exceptions
".
exception_index_table[i]
!= 0, where 0 <= i
< number_of_exceptions
), then constant_pool[exception_index+table[i]]
is a Exception that this class is declared to throw.
LineNumberTable_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 line_number_table_length;
{ u2 start_pc;
u2 line_number;
} line_number_table[line_number_table_length];
}
constant_pool[attribute_name_index]
will be the CONSTANT_Utf8
string "LineNumberTable
".
source_p
c <<SHOULD THAT BE start_pc
?>> is an offset from the beginning of the code.
LocalVariableTable_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 local_variable_table_length;
{ u2 start_pc;
u2 length;
u2 name_index;
u2 signature_index;
u2 slot;
} local_variable_table[local_variable_table_length];
}
constant_pool[attribute_name_index]
will be the CONSTANT_Utf8
string "LocalVariableTable
".
start_pc
and start_pc
+ length
. The two values are both offsets from the beginning of the code.
constant_pool[name_index]
and constant_pool[signature_index]
are CONSTANT_Utf8
strings giving the name and signature of the local variable.