Contents Prev Next Up
2.4 Fields
The information for each field immediately follows the field_count field in the class file. Each field is described by a variable length field_info structure. The format of this structure is as follows:
field_info {
u2 access_flags;
u2 name_index;
u2 signature_index;
u2 attributes_count;
attribute_info attributes[attribute_count];
}
access_flags
This is a set of sixteen flags used by classes, methods, and fields to describe various properties and how they many be accessed by methods in other classes. See the table "Access Flags" on page 12 which indicates the meaning of the bits in this field.
The possible fields that can be set for a field are ACC_PUBLIC
, ACC_PRIVATE
, ACC_PROTECTED
, ACC_STATIC
, ACC_FINAL
, ACC_VOLATILE
, and ACC_TRANSIENT.
At most one of ACC_PUBLIC
, ACC_PROTECTED
, and ACC_PRIVATE
can be set for any method.
name_index
constant_pool[name_index]
is a CONSTANT_Utf8
string which is the name of the field.
signature_index
constant_pool[signature_index]
is a CONSTANT_Utf8
string which is the signature of the field. See the section "Signatures" for more information on signatures.
attributes_count
This value indicates the number of additional attributes about this field.
attributes
A field can have any number of optional attributes associated with it. Currently, the only field attribute recognized is the "ConstantValue" attribute, which indicates that this field is a static numeric constant, and indicates the constant value of that field.
Any other attributes are skipped.
Contents Prev Next Up