In this work we describe the Java virtual machine class file format. Each file contains the definition of a class or an interface. Although a class and an interface doesn't always need file external representation. We will refer to each valid representation of a class or interface as being in the class format.
A class file contains strings of 8 bit bytes. All the 16, 32, 64 groups of bits are built by reading consecutive 2, 4 or 8 bytes. The data represented on multiple bytes are using the big-endian ordering (the most important byte is the first). On the Java and Java 2 platforms we have interfaces and classes that have this format: interfaces java.io.DataInput, java.io.DataOutput and classes java.io.DataInputStream, java.io.DataOutputStream.
Types u1, u2, u3, u4 are defined representing 1,2,3,4 bytes.
In this work we present the format of the class files using pseudo-structures written in a C-like programming language. In order to avoid confusion between class fields or their instances, the content of the structures describing the format of the class files will be named items. Successive items are stored in the class file in a sequence without indentation or spacing.
Tables containing zero or more entities are used in multiple structures of the class file. Even if we use C-like structures, the tables are streams of structures with variable width, meaning that it is not possible to translate the table index in the offset of the global table.
We will refer to data structures as to a table, this will contain zero or multiple entities that can be indexed as an table.
A class file contains the declaration of the ClassFile structure:
ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; }
The entities from the ClassFile structure are the following:
The magic entity is a magic number that identified the class format and has the value of 0xCAFEBABE.
The values of minor_version and major_version determine the version of the class file format.
Thus, the class versions can be ordered lexicographically.
For example, 1.5<2.0<2.1, where the version if given by the M.m construction where
M is the major version and
m is the minor version.
A Java virtual machine can accept a class format v if v is in the range Mi.0<v<=Mj.m.
The value of the constant_pool_count entity is equal to the number of entries from the constant_pool table plus one. A index in the table of constants is valid if it is greater than zero and less than constant_pool_count, except of the constants of type long or double.
The table of constants is a table of structures representing several constants of type string like: class names, interface names, field names and other constants that will be referred in the structures and substructures of ClassFile. The format of the first entrance from each table of constants is pointed out by the first byte of the label. The table of constants is indexed from 1 to constant_pool_count-1.
The entity names access_flags is a mask of flags which contain the access permissions and the properties of the class or the interface. The interpretation of each flag is given in the following table:
Flag Name | Value | Interpretation |
ACC_PUBLIC | 0x0001 | Declared as public, can be accessed from the outside of the package. |
ACC_FINAL | 0x0010 | Declared as final, subclasses are not allowed. |
ACC_SUPER | 0x0020 | Treats the superclass methods in a special way when they are invoked by the instruction invokespecial. |
ACC_INTERFACE | 0x0200 | Represents an interface and not a class. |
ACC_ABSTRACT | 0x0400 | Declared as abstract, it can not be instantiated. |
An interface has the ACC_INTERFACE flag set. If this flag is not set then the class file defines a class and not an interface.
If the ACC_INTERFACE flag is set then the ACC_ABSTRACT flag must be set. The ACC_PUBLIC flag may be set. Such a class file can not have other flags set in the table.
If the ACC_INTERFACE flag is not set then the class file may have the other flags set. Still, such a class can not have the ACC_FINAL and ACC_ABSTRACT flags as set.
Setting the ACC_SUPER flag selects one of the two alternatives for the semantic of the invokespecial instruction to be used. The ACC_SUPER flag exists for the compatibility of the compiled code by the older Sun Company compilers. All the new virtual machine implementations must implement the semantics of the invokespecial instruction corresponding to the ACC_SUPER flag as set.
All the bits from the access_flags entity that are not yet assigned in the previous table are reserved for future uses. These should be unset (or set to zero) in the generated class file and ignored by the virtual machine.
The value of the this_class entity must be a valid index in the constant table. The pointed entry in the constant table must be an entrance of CONSTANT_Class_info type representing the class or the interface defined by the current file.
For a class the value of this entity must be null or a valid entrance in the constant table. If the value of the entity is non-null then the entrance must be of type CONSTANT_Class_info representing the super class of the class defined by the current class file. Neither the direct superclass nor the indirect superclasses can not have the attribute of final class.
If the value of the super_class entity is zero then this class must represent the Object class, which is the only class or interface that doesn't have a direct superclass.
For an interface, the value of the super_class entity must be a valid index in the table of constants. The index must represent an entry from the constant table of type CONSTANT_Class_info structure representing the Object class.
The value of the interfaces_count item gives the number of direct superinterfaces of this class or interface type.
Each value from the table of interfaces must be a valid index in the table of constants. Each entrance from the table of constants indexed with the interface[i] index having 0<=i<=interfaces_count must point to a CONSTANT_Class_info type structure representing an interface that is a direct superinterface of the current class or interface. The order of the superinterfaces declaration corresponds to the order in the table of interfaces.
The value of this entity tells us how many field type structures are in the table of fields. The field_info structure stores all fields that may be static or non-static attributes of the current class or interface.
Each value from the table of fields must be an element of the field_info structure type that describes completely a field if the current class or interface. The table of fields contain only the fields declared in the current class or interface. There are not included the inherited fields from the superclass or superinterfaces.
The value of the method_count entity tells us the number of method_info structures from the method table.
Each value from the method table have to be a sequence such as method_info which describes fully any method from current class or interface. If the method is not native or abstract than the instructions of the Java virtual machine, which implements this method, are provided.
The method table with sequences such as method_info contains all the methods declared in this class or interface including static and non-static methods, the initialize constructors for instances and the initialize methods for class or interface. The method table doesn't include the entities which represent methods which are inherited from superclasses and superinterfaces.
The value of attributes_count represent the number of attributes from the attributes table of the class.
Each element from the attribute table must be a sequence attribute which will be described in detail later.
The only attributes we will remind are SourceFile and Deprecated.
The implementation of the Java virtual machine will silently ignore all the attributes which we won't know. The undefined attributes are not allowed to alternate programming language definition of the class file, they have the role just to bring supplementary descriptive information.
The name of classes and interfaces appear in the class file structure and are always represented in qualified form. This names are represented by sequences such as CONSTANT_Utf_8_info. The name of classes and interfaces are references from sequences CONSTANT_NameAndType_info which name of class and interface have in their composition also from sequences CONSTANT_Class_info.
From historically motives the classes and interfaces names which appear in the intern representation of the class files are different from the representation which they have in the Java language. In the intern representation form the dot "." Is substituted by slash "/". For example the canonic name of class Thread is a constant of type CONSTANT_Utf8_info with value "java/lang/Thread".
A descriptor is a string which describes the signature of a field or a method. The descriptors are defined like strings UTF-8.
The descriptors are specified using a grammar. This grammar shows us based on some productions which are the character sequences which can form right descriptors from different kind. As a convention the terminal notations are written in bold an unfinished are written in italic. For example the production from below shows us that the type of a field could be a base type, an object type or a table type.
FieldType:
BaseType
ObjectType
tableType
An unfinished symbol followed by asterisk (*) means that symbol could appear zero or more times. The next production specifies the fact that a MediaDescriptor contins an open bracket, followed by the repetition of zero or more or a ParameterDescriptor, o closed bracket followed by ReturnDescriptor.
MethodDescriptor:
( ParameterDescriptor* )
ReturnDescriptor
A field descriptor represent a the type of a class, an instance, a local variable. The descriptor is given by the next grammar:
FieldDescriptor: FieldType ComponentType: FieldType FieldType: BaseType ObjectType tableType BaseType: B C D F I J S Z ObjectType: L<classname>; tableType: [ComponentType
The characters from BaseType, the characters L and ";" from ObjectType and the character [ from TableType are all ASCII characters. The terminal <classname> represents the canonic name of the class or interface.
The interpretation of the types which appear in a field signature is given in the table below:
BaseType Character Code | Type | Interpretation |
B | byte | signed byte |
C | char | Unicode character |
D | double | double-precision floating-point value |
F | float | single-precision floating-point value |
I | int | integer |
J | long | long integer |
L<classname>; | reference | an instance of class <classname> |
S | short | signed short |
Z | boolean | true or false |
[ | reference | one table dimension |
For example,the descriptor for a type int variable is I. The descriptor of a instance type Object is Ljava/lang/Object;. We remark that the intern representation is used for the canonic name of a class. The descriptor for a variable which has a multidimensional table type double
double d[][][];
is
[[[D
A method descriptor represents parameters which the method receives and the returned value:
MethodDescriptor:
( ParameterDescriptor* ) ReturnDescriptor
A parameter descriptor represents the parameter which will be transmitted to the method
ParameterDescriptor:
FieldType
The returning descriptor represents the type of the method returned value. This is a series of characters generated by grammar:
ReturnDescriptor:
FieldType
V
The character V means that the method doesn't return any value(returns void type).
A method descriptor is valid if represents the parameters in length of 255 or less. The length include this in case of a method or interface appealed from interface. The total length is calculated by summing every parameter length which a type long parameter or a double one can occupy two unities, and the remaining types just one unity.
For example the descriptor for method
Object mymethod(int i,double d, Thread t)
is
(IDLjava/lang/Thread;)Ljava/lang/Object;
We can notice that for the classes name Thread and Object were used the canonic names in the componence of the method descriptor.
The method descriptor for the method mymethod is identical even if the method is part of a class or interface.
The instructions of Java virtual machine isn't based by the classes structure, interfaces, instances or tables during building. Instead the virtual machine refers symbolic information from the constant table.
All the entries from the constant table constant_pool have the next general format:
cp_info {
u1 tag;
u1 info[];
}
Each constant form the constant table must to begin with an octet indicating the entry type cp_info. The value table info variates depending the label symbol tag. The values valid for labels and their value are listed in the next table. Each label must be followed by one or more octets which will provide information about a certain type of constant. The format of the additional information variates depending the label value.
Constant Type |
Value |
CONSTANT_Class | 7 |
CONSTANT_Fieldref | 9 |
CONSTANT_Methodref | 10 |
CONSTANT_InterfaceMethodref | 11 |
CONSTANT_String | 8 |
CONSTANT_Integer | 3 |
CONSTANT_Float | 4 |
CONSTANT_Long | 5 |
CONSTANT_Double | 6 |
CONSTANT_NameAndType | 12 |
CONSTANT_Utf8 | 1 |
The structure CONSTANT_Class_info is used for representing a class or interface:
CONSTANT_Class_info {
u1 tag;
u2 name_index;
}
The components of the structure CONSTANT_Class_info are the following:
tag
The field tag has the value CONSTANT_Class (7).name_index
The value of name_index must be a valid index in the constant table constant_pool. The entry constant_pool from that index must be a structure CONSTANT_Utf8_info representing a canonic name of a class or interface in the intern representation format.Because the tables are objects the instructions anewtable and multianewtable can refer classes of table type through sequences such as CONSTANT_Class_info in the constant table constant_pool. For this kind of classes of type table, the class name represent the table type descriptor. For example the class name representing a bidimensional table of type int
int[][]
is
[[I
The class name representing the type of table of objects Thread
Thread[]
is
[Ljava/lang/Thread;
A descriptor of type table is valid if it has maximum 255 dimensions.
The fields, the methods and the interfaces of methods are represented by similar structures:
CONSTANT_Fieldref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
CONSTANT_Methodref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
CONSTANT_InterfaceMethodref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
The fields of those structure are the following:
tag
The value of field tag for the structure CONSTANT_Fieldref_info is CONSTANT_Fieldref (9). The value of field tag for the structure CONSTANT_Methodref_info is CONSTANT_Methodref (10). The value of field tag for the structure CONSTANT_InterfaceMethodref_info is CONSTANT_InterfaceMethodref (11).class_index
The value of field class_index trebuie must be a valid index in the constant table. The entry from the table must be a structure of type CONSTANT_Class_info representing the class or interface containing the declaration of the field or method. The field class_index from the structure CONSTANT_Methodref_info must be a class type, but not an interface type. The field class_index from the structure CONSTANT_InterfaceMethodref_info must be an interface type. The field class_index from the structure CONSTANT_Fieldref_info can be a class type or an interface type.name_and_type_index
The value of field name_and_type_index must be a valid index in ta constant table constant_pool. The suitable entry of that index must be a field descriptor or a method. In a structure CONSTANT_Fieldref_info the indicated descriptor must be a field descriptor. Otherwise the indicated descriptor must be a method descriptor. If the name of the method from the structure CONSTANT_Methodref_info begins with < than the name must be <init> representing a initializing method for the object (constructor). This kind of method doesn't return any value.The structure CONSTANT_String_info is used for representing the constant objects of type String:
CONSTANT_String_info {
u1 tag;
u2 string_index;
}
The entities from structure CONSTANT_String_info are the following:
tag
The field tag from CONSTANT_String_info has the value CONSTANT_String(8).
string_index
The value of field string_index must be a valid index in the constant table. The suitable entry from the constant table must be a structure of type CONSTANT_Utf8_info representing a sequence of characters which the object of type String are initialized.
The structures CONSTANT_Integer_info and CONSTANT_Float_info represent numeric constant integer and float represented on 4 bytes.
CONSTANT_Integer_info {
u1 tag;
u4 bytes;
}
CONSTANT_Float_info {
u1 tag;
u4 bytes;
}
The field of those structures are the following:
tag
The field tag of the structure CONSTANT_Integer_info has the value CONSTANT_Integer(3). The field tag of the structure CONSTANT_Float_info has the value CONSTANT_Float(4).bytes
The field bytes of the structure CONSTANT_Integer_info represent the value of the integer constant. The bytes store the value in big-endian. The bytes from the field bytes of the structure CONSTANT_Float_info represent the value of a constant in a mobile comma in simple precision in the format IEEE 754. The representation bytes are stored in order in big-endian (the first ones are the considerable bytes).The structures CONSTANT_Long_info and CONSTANT_Double_info represent the numeric constants of type long and double.
CONSTANT_Long_info {
u1 tag;
u4 high_bytes;
u4 low_bytes;
}
CONSTANT_Double_info {
u1 tag;
u4 high_bytes;
u4 low_bytes;
}
All the constants with 8 bytes occupy two entries in the constant table from the file class. If a structure of the types enumerated above is localized on the entry n than the next entity can be found at the index n+2. The entry n+1 from the constant table must be valid , but is considered that it cannot be used.
The fields of this structure are the following:
tag
The field tag of a structure of type CONSTANT_Long_info has the value CONSTANT_Long (5).
The field tag of a structure of type CONSTANT_Double_info has the value CONSTANT_Double (6).
high_bytes, low_bytes
The bytes without a sign high_bytes and low_bytes from the structure CONSTANT_Long_info represent the value of a constant of type long after formula (( long) high_bytes << 32) + low_bytes where the bytes high_bytes and low_bytes are stored in the format big-endian.
The bytes without sign high_bytes and low_bytes from the structure CONSTANT_Double_info represent the constant value of type float in float comma with double precision IEEE754. The bytes high_bytes and low_bytes are stored in big-endian format.
The structure CONSTANT_NameAndType_info is used for the representation of fields and methods without indicating the class or interface which they belong:
CONSTANT_NameAndType_info {
u1 tag;
u2 name_index;
u2 descriptor_index;
}
The fields of the structure CONSTANT_NameAndType_info are the following:
tag
The field tag from the structure CONSTANT_NameAndType_info has the value CONSTANT_NameAndType(12).
name_index
The value of field name_index trebuie must be a valid index from the constant table. The entry from th constant must be a structure type of CONSTANT_Utf8_info representing a valid field or a method stored with a simple name, for example with a Java identifier or like a special method name <init>.
descriptor_index
The value of descriptor_index must be a valid index in the constant table. The entry on that index must be a structure of type CONSTANT_Utf8_info representing a valid descriptor field or method.
The structure CONSTANT_Utf8_info is used for representing values of type string.
The structure CONSTANT_Utf8_info is the following:
CONSTANT_Utf8_info {
u1 tag;
u2 length;
u1 bytes[length];
}
The entities of the structure CONSTANT_Utf8_info are the following:
tag
The entity tag from the structure CONSTANT_Utf8_info has the value CONSTANT_Utf8 (1).
length
The value of entity length memorize the number of bytes from the table bytes (and not the length of the resulted string). The strings from the structure CONSTANT_Utf8_info are not finished with the null character.
bytes[]
The table bytes contains bytes from the string. The bytes can't have the zero value or be in the (byte)0xf0-(byte)0xff interval.
Each field is described by a structure of type field_info. It doesn't exist two fields with the same name and the same descriptor. The format of these structure is the following:
field_info {
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
attribute_info attributes[attributes_count];
}
The fields from the structure field into are the following:
access_flags
The entities value of access_flags is a mask of flags used for shaping the accessing permissions and field properties. The semantics if each flag is given in the next table.
The classes fields can be combined by the flags from the table. However a field can have just one of the flags ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC set and it can't have both flags ACC_FINAL and ACC_VOLATILE set simultaneously.
Flag Name | Value | Interpretation |
ACC_PUBLIC | 0x0001 | Public declared; can be accessed from outside the package. |
ACC_PRIVATE | 0x0002 | Private declared; usable just from the inside of the class which its defined. |
ACC_PROTECTED | 0x0004 | Protected declared; can be accessed just in subclasses. |
ACC_STATIC | 0x0008 | Static declared. |
ACC_FINAL | 0x0010 | Final declared; it's not possible attributions after the initialization. |
ACC_VOLATILE | 0x0040 | Volatile declared; can't be cache-at. |
ACC_TRANSIENT | 0x0080 | Transient declared; can't be written or read by a manager of persistent objects. |
All the fields of an interface must have the flags ACC_PUBLIC, ACC_STATIC and ACC_FINAL set and it can't have other flags from the table set.
All other bits from the entity access_flags are reserved for further utilizations. They must be set on zero in their generated class files and ignored by the implementation of the Java virtual machines.
name_index
The entity value name_index must be an valid index in the constant table constant_pool. This entry must be a structure of type CONSTANT_Utf8_info which represents a valid field name stored like a simple name, like a Java identifier.
descriptor_index
The entity value descriptor_index must be a valid index from the constant table. That entry must be a structure type of CONSTANT_Utf8_info and to represent a valid field descriptor.
attributes_count
The entity value attributes_count indicates the number of the additional attributes of these field.
attributes[]
Each value from the attributes table must pe a structure of type attribute. A field can have no matter how much attributes associated with him.
The defined attributes of these specification which appear in the attribute table from the structure field_info are ConstantValue, Synthetic and Deprecated.
An implementation of Java virtual machine must recognize and read correctly the attribute ConstantValue. Also it must ignore all the attributes from the table which it doesn't recognize. The attributes which are not defined in this specification are not allowed the affect the semantic of the class file, just to bring supplementary descriptive information.
Each method, either is an initialization method of instances or initialization of interfaces or classes, is described by structure method_info. It doesn't exist two methods in a class which have the same name and descriptor.
The structure has the following format:
method_info {
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
attribute_info attributes[attributes_count];
}
The entities from the structure method_info is the following:
access_flags
The entity value of access_flags is a flag mask used for restraining the acces rights and properties of these method. The interpretation of each flag is given in the next table:
Flag Name | Value | Interpretation |
ACC_PUBLIC | 0x0001 | Public declared; can be accessed from outside the package. |
ACC_PRIVATE | 0x0002 | Private declared; accessible just from the inside of the defined class. |
ACC_PROTECTED | 0x0004 | Protected declared; can be accessed from the subclasses. |
ACC_STATIC | 0x0008 | Static declared. |
ACC_FINAL | 0x0010 | Final declared; can't be overwritten. |
ACC_SYNCHRONIZED | 0x0020 | Synchronized declared; the appeal is associated with a screen blocking. |
ACC_NATIVE | 0x0100 | Native declared; implemented in other Java language. |
CC_ABSTRACT | 0x0400 | Abstract declared; it doesn't have implementation. |
ACC_STRICT | 0x0800 | Strictfp declared; the work mode in flotant comma is FP-strict. |
The class methods can have set any combinations of flags from the table. However a method can't have set simultaneously the flags ACC_PRIVATE, ACC_PROTECTED and ACC_PUBLIC. If a method has the flag ACC_ABSTRACT set than it can't have set none of the flags ACC_FINAL, ACC_NATIVE, ACC_STATIC, ACC_STRICT or ACC_SYNCHRONIZED.
All the methods from the interface must have set the flags ACC_ABSTRACT and ACC_PUBLIC set and they can't have the other flags set instead.
A method of initializing for the instance must have at least of the flags ACC_PRIVATE, ACC_PROTECTED or ACC_PUBLIC set and also it can have the flag ACC_STRICT, but it can't have any other flag set from the table.
The initialization methods of the classes and methods are appealed by the Java virtual machine, the entity value access_flags is ignored with the exception of flag ACC_STRICT.
All the bits from access_flags which are not assigned in the table will be reserved for further utilizations. They will be set on zero in the class files and will be ignored by the implementation of Java virtual machine.
name_index
The entity value name_index must be an valid index in the constant table . The entry of that index must be a structure of type CONSTANT_Utf8_info representing one of the methods names <init> or <clinit> or a valid method name, stored like a simple name.descriptor_index
The entity value of descriptor_index must be a valid index in the constant table . The entry from the constant table of that index must pe an entry structure type of CONSTANT_Utf8_info representing a valid descriptor of method.attributes_count
The entity value of attributes_count represent the number of additional attributes of these method.attributes[]
Each value of the attribute table must be an attribute structure. A method can have as may associated attributes it wants. The only defined attributes of these specifications appearing in the attributes table from structure method_info are Code, Exceptions, Synthetic and Deprecated. An implementation of Java virtual machine must recognize and read correctly the attributes Code and Exceptions from the attributes table of structure method_info. An implementation of Java virtual machine must ignore silently all other attributes defined in the attributes table from structure method_info and which it don't recognize. The attributes that are not defined in the specification are not allowed to affect the semantic of the class file, just to bring additional descriptive information.The attributes are used in the structures ClassFile, field_info, method_info and Code_attribute from the class format. All the attributes have the following general format :
attribute_info {
u2 attribute_name_index;
u4 attribute_length;
u1 info[attribute_length];
}
For all the attributes, the entity attribute_name_index must be a valid index of 16 bits form the constant table. The index entry attribute_name_index must be a structure of type CONSTANT_Utf8_info representing the attribute name. The entity value attribute_length shows the length of the information in bytes. The length doesn't include the initial 6 bytes which contain the entities attribute_name_index and attribute_length.
Some attributes are predefined and represents a part from the specifications of the class file. The predefined attributes are SourceFile, ConstantValue, Code, Exceptions, InnerClasses, Synthetic, LineNumberTable, LocalVariableTable, Deprecated. In this context using this attributes, according to this specifications, in the attributes table from the class file structure, this predefined attributes names are reserved.
Among the predefined attributes, the attributes Code, ConstantValue and Exceptions must be recognized and interpreted correctly by the Java virtual machine implementation. The attributes InnerClasses and Synthetic must be recognized and interpreted correctly by a class reader for the correct implementation of the Java platform libraries and Java 2. The using of the rest of the predefined attributes is optional, a class reader can use this information followed by attributes or it must ignore them. 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 structure entities of Code_attribute are the folowing:
attribute_name_index
The entity value of attribute_name_index must be a valid index from the constant table. The
entry from the constant table must be a structure CONSTANT_Utf8_info representing the string
„Code”.
attribute_length
The entity value of attribute_length indicates the length excluding the initial 6 bytes.
max_stack
The entity value of max_stack gives us the maximum depth for the stack of the method in any part
of the method execution.
max_locals
The entity value of max_locals gives us the number of local variables from the local variable table
allocated on the method appeal, including the local variables used for transmitting the parameters
in the context of method appeal.
The biggest index for a local variable of type long or double is e max_locals-2.
The biggest index for a value of any other kind is max_locals-1.
code_length
The entity value of code_length contains the number of bytes from the code table of the method.
The value of code_lenght must be bigger than zero, and the code table is not allowed to be vacuum.
code[]
The code table contains the bytes of Java virtual machine that implements the method.
When the code table is storage in the memory on a machine that addresses bytes, if the first byte
from the table is aligned on a frontier of 4 bytes than the offsets of 32 bits tableswitch and
lookupswitch will be also aligned on 4 bytes.
The detailed constrains referring to the code table are elaborated and will ve presented in
another section.
exception_table_length
The entity value of exception_table_length contains the number of entries from the table tabela
exception_table.
exception_table[]
Each entry from the exeption table exception_table describes an exception manipulator from the
code table. The manipulator order from the table is important.
Each entry from the exception table of exception_table contain the following 4 entities:
start_pc
,
end_pc
The entity value of start_pc and end_pc indicates the space from the code table on which the
exception manipulator is active. The value start_pc trebuie must be a valid index in the code
table. The value end_pc trebuie must be a valid index in the code table or it needs to be equal
with code_length, the length of the code table. The value start_pc must be lower than the value
of end_pc.
The counter of instructions start_pc has an inclusive character and the counter of intructions
end_pc has an exclusive character, it means that the exception manipulator must be active when the
counter of instructions is in between [start_pc, end_pc).
handler_pc
The entity value of handler_pc indicates the start of the exception manipulator. The value of this
entity must be a valid index from the code table and must represent the index of an instruction
of memory.
catch_type
If the entity value catch_type is nonzero then it must be a valid index in the constant table
constant_pool. The entry from tabela constant_pool at that index must be a structure structura
CONSTANT_Class_info representing a class of exceptions that this manipulator of exceptions
must catch. This class must be Throwable or a subtype of this. The exceptions manipulator will
be appealed if the exception is generated by an instance of a data class or a subclass.
If the entity value catch_type is zero than this manipulator of exceptions is appealed for all
the exceptions. This value is used for implementing the clause finally.
attributes_count
The entity value of attributes_count indicates the number of attributes of the Code attribute.
attributes[]
Each value of the attributes table must be a structure of type attribute. A Code attribute can
have as many as associate optional attributes it want with it.
The attributes LineNumerTable and LocalVariableTable which can contain information troubleshooting
are defined and used with the Code attribute.
An implementation of Java virtual machine can ignore any of the attributes from the attribute table
of the Code attribute. The undefined attributes in this specifications are not allowed to affect
the semantic of the class file just to bring supplementary descriptive information.