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[attribute_count];
}
n
of a particular major version number. If the minor version number is incremented the new code won't run on the old virtual machines, but it is possible to make a new virtual machine which can run versions up to n
+1.A change of the major version number indicates a major incompatible change, one that requires a different virtual machine that may not support the old major version in any way.
The current major version number is 45; the current minor version number is 3.
constant_pool[0]
is always unused by the compiler, and may be used by an implementation for any purpose.
Each of the constant_pool
entries 1 through constant_pool_count-1
is a variable-length entry, whose format is given by the first ''tag'' byte, as described in section 2.3.
field_info
and method_info
as described below. Here is the encoding:
Flag Name | Value | Meaning | Used By |
ACC_PUBLIC | 0x0001 | Visible to everyone | Class, Method, Variable |
ACC_PRIVATE | 0x0002 | Visible only to the defining class | Method, Variable |
ACC_PROTECTED | 0x0004 | Visible to subclasses | Method, Variable |
ACC_STATIC | 0x0008 | Variable or method is static | Method, Variable |
ACC_FINAL | 0x0010 | No further subclassing, overriding, or assignment after initialization | Class, Method, Variable |
ACC_SYNCHRONIZED | 0x0020 | Wrap use in monitor lock | Method |
ACC_VOLATILE | 0x0040 | Can't cache | Variable |
ACC_TRANSIENT | 0x0080 | Not to be written or read by a persistent object manager | Variable |
ACC_NATIVE | 0x0100 | Implemented in a language other than Java | Method |
ACC_INTERFACE | 0x0200 | Is an interface | Class |
ACC_ABSTRACT | 0x0400 | No body provided | Class, Method |
constant_pool[this_class]
must be a CONSTANT_class.
super_class
is nonzero, then constant_pool[super_class]
must be a class, and gives the index of this class's superclass in the constant pool.
If the value of super_class
is zero, then the class being defined must be java.lang.Object
, and it has no superclass.
interfaces[i]
!= 0, where 0 <= i
< interfaces_count
), then constant_pool[interfaces[i]]
must be an interface that this class implements.Question: How could one of these entries ever be 0?
fields
table includes only those variables that are defined explicitly by this class. It does not include those instance variables that are accessible from this class but are inherited from superclasses.
field_info
structure.
method_info
structure.
attribute_info
structure.