|
|
The Version Region
In anticipation of future development in Java, the class file format was created with a version stamp of sorts. The Version Region holds the version number of the compiler that created the class file. This is used to specify incompatible changes to either the format of the class file or JVM instruction set changes. In this way, the Java runtime environment can quickly and accurately determine compatibility.
The constant_pool Region
A familiar mechanism used in the class file format is to provide a region that specifies the size of another contained region. In this way, regional boundaries can be dynamically adjusted as needed. The constant_pool_count specifies the size of the next region, which is the constant_pool region.
The constant_pool contains an array of (constant_pool_count - 1) in size, which stores string constants, class names, field names, and all constants referenced in the body of the code. For each element in the constant_pool array, the first byte contains a type specifier, specifying the content of the entry. Although the type specifier values are not testable items, Table 1.1 provides the type values for reference purposes.
Table 1.1 Table of constant types.
|
Constant Type
| Value
| Storage
|
|
CONSTANT_Asciiz
| 1
| 1-byte reference tag, 2-byte length specifier, and array of bytes of that specified length
|
CONSTANT_Unicode
| 2
| 1-byte reference tag, 2-byte length specifier, and array of bytes of that specified length
|
CONSTANT_Integer
| 3
| 1-byte reference tag and 4-byte value
|
CONSTANT_Float
| 4
| 1-byte reference tag and 4-byte value
|
CONSTANT_Long
| 5
| 1-byte reference tag, 4-byte value containing the high bytes, and 4-byte value containing the low bytes
|
CONSTANT_Double
| 6
| 1-byte reference tag, 4-byte value containing the high bytes, and 4-byte value containing the low bytes
|
CONSTANT_Class
| 7
| 1-byte reference tag and 2-byte index into the constant_pool containing classs string name
|
CONSTANT_String
| 8
| 1-byte reference tag and 2-byte index into constant_pool holding the actual string value encoded using a modified UTF scheme
|
CONSTANT_Fieldref
| 9
| 1-byte reference tag and two 2-byte indexes
|
CONSTANT_Methodref
| 10
| 1-byte reference tag and two 2-byte indexes into constant_pool
|
CONSTANT_InterfaceMethodref
| 11
| 1-byte reference tag and two 2-byte indexes
|
CONSTANT_NamedType
| 12
| 1-byte tag and two 2-byte indexes into constant_pool
|
|
The access_flags Region
Chapter 2, Java Language Internals, explores the various types of class accessor modifiers. For now, you need only know that the class accessor modifiers simply limit class users. For example, say you create a class you want to be used only by other classes you create. To limit the classes from which your class can be used, you would specify the appropriate accessor modifiers.
The access_flags region holds the classs visibility information. This information is stored as a 2-byte field that specifies 16 different values describing various properties of fields, classes, and methods. Although the access flag values are not testable items, Table 1.2 provides the flag values for reference purposes.
Table 1.2 Table of access flags.
|
Constant Name
| Value
|
|
ACC_PUBLIC
| 0x0001
|
ACC_PRIVATE
| 0x0002
|
ACC_PROTECTED
| 0x0004
|
ACC_STATIC
| 0x0008
|
ACC_FINAL
| 0x0010
|
ACC_SYNCHRONIZED
| 0x0020
|
ACC_THREADSAFE
| 0x0040
|
ACC_TRANSIENT
| 0x0080
|
ACC_NATIVE
| 0x0100
|
ACC_INTERFACE
| 0x0200
|
ACC_ABSTRACT
| 0x0400
|
|
|