next up previous contents
Next: The JVM Instruction Up: The Java Class Previous: The Class File

Fields in a Class File

magic

This field holds the magic number 0xcafebabe that identifies a Java class file.

minor_version, major_version

These fields hold the minor and major version numbers of the compiler that produced this class file. A JVM supports class files having a given major version number and minor version numbers 0 through some particular minor_version.

constant_pool[]

This is a table of constant_pool_count - 1 structures representing various constant values, names, descriptors and other things that are referred to within the class file. There is no entry 0; this entry is reserved for internal use by a JVM. Each of the entries have a tag to indicate its type.

The following table contains a list of the types and their description:

Structures of type CONSTANT_Long and CONSTANT_Double take up two entries in the constant_pool for historic reasons.

access_flags

This is a mask of modifiers used with class and interface declarations. The following flags are defined:

this_class
This is an index into the constant_pool[]. The entry at that index must be a CONSTANT_Class_info representing the class or interface defined by this file.

super_class
For a class the value of this field is either zero, in which case this class file represents the class java.lang.Object, or an index into the constant_pool[]. The entry at that index must be a CONSTANT_Class_info representing the superclass of the class defined by this class file.

For an interface the value of this field must always be an index into the constant_pool[]. The entry at that index must be a CONSTANT_Class_info representing the class java.lang.Object.

interfaces[]
Each value in this table with interfaces_count entries must be an index into the constant_pool[], the entry at that index must be a CONSTANT_Class_info representing an interface which is a direct superinterface of this class or interface.

fields[]
Each entry in this table with fields_count entries is a complete description of a field.

methods[]
Each entry in this table with methods_count entries gives a complete description of and JVM code for a method in the class or interface.

attributes[]
Each entry in this table with attributes_count entries must be a variable-length attribute structure. For the class file the only attribute defined is the SourceFile attribute containing the name of the source file.

The fields described here are the main fields of the class file structure. The other fields (i.e. the fields in the constant_pool[], fields[], methods[] and attributes[] tables) are described in [JVM].



next up previous contents
Next: The JVM Instruction Up: The Java Class Previous: The Class File



mark@bottom.xs4all.nl