Java Reference
In-Depth Information
Attribute Description
magic A magic number (0xCAFEBABE) identifying the
class file format.
minor_version,major_version Together, a major and minor version number de-
termine the version of the class file format. A
JVM implementation can support a class file for-
mat of version v if and only if v lies in some con-
tiguous range of versions. Only Oracle specifies
the range of versions a JVM implementation may
support.
constant_pool_count Number of entries in the constant_pooltable
plus one.
constant_pool[] A table of structures representing various string
constants, class and interface names, field names,
and other constants that are referred to within
the ClassFile structure and its sub-structures.
access_flags Mask of flags used to denote access permissions
to and properties of this class or interface.
this_class Must be a valid index into the constant_pool
table. The entry at that index must be a structure
representing the class or interface defined by this
class file.
super_class Must be a valid index into the constant_pool ta-
ble. The entry at that index must be the structure
representing the direct super class of the class or
interface defined by this class file.
interfaces_count The number of direct super interfaces of the class
or interface defined by this class file.
interfaces[] Each value in the table must be a valid index into
the constant_pool table. The entry at each in-
dex must be a structure representing an interface
that is a direct super interface of the class or in-
terface defined by this class file.
fields_count Number of entries in the fields table.
fields[] Each value in the table must be a field_info
structure giving complete description of a field in
the class or interface defined by this class file.
methods_count Number of entries in the methods table.
methods[] Each value in the table must be a method_info
structure giving complete description of a method
in the class or interface defined by this class file.
attributes_count Number of entries in the attributes table.
attributes[] Must be a table of class attributes.
The internals for all of these are fully described in [Lindholm and Yellin, 1999].
One may certainly create class files by directly working with a binary output stream.
However, this approach is rather arcane, and involves a tremendous amount of housekeeping;
one has to maintain a representation for the constant_pool table, the program counter pc ,
compute branch offsets, compute stack depths, perform various bitwise operations, and do
much more.
It would be much easier if there were a high-level interface that would abstract out the
gory details of the class file structure. The CLEmitter does exactly this.
 
Search WWH ::




Custom Search