The CAP File Format
6.7 Constant Pool Component
6.7.2 CONSTANT_InstanceFieldref,
CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref
References to instance fields, and virtual methods are represented by similar structures:
The items in these structures are as follows:
tag
The tag item of a CONSTANT_InstanceFieldref_info structure has the value CONSTANT_InstanceFieldref (2).
The tag item of a CONSTANT_VirtualMethodref_info structure has the value CONSTANT_VirtualMethodref (3).
The tag item of a CONSTANT_SuperMethodref_info structure has the value CONSTANT_SuperMethodref (4).
class
The class item represents the class associated with the referenced instance field, virtual method, or super method invocation. It is a class_ref structure (§6.7.1). If the referenced class is defined in this package the high bit is equal to zero. If the reference class is defined in an imported package the high bit of this structure is equal to one.
The class referenced in the CONSTANT_InstanceField_info structure must be the class that contains the declaration of the instance field.
The class referenced in the CONSTANT_VirtualMethodref_info structure must be a class that contains a declaration or definition of the virtual method.
The class referenced in the CONSTANT_SuperMethodref_info structure must always be internal to the class that defines the method that contains the Java language-level super invocation. The class must be defined in this package.
token
The token item in the CONSTANT_InstanceFieldref_info structure repre-sents an instance field token (§4.3.7.5) of the referenced field. The value of the instance field token is defined within the scope of the class indicated by the class item.
The token item of the CONSTANT_VirtualMethodref_info structure repre-sents the virtual method token (§4.3.7.6) of the referenced method. The virtual method token is defined within the scope of the hierarchy of the class indicated by the class item. If the referenced method is public or protected the high bit of the token item is zero. If the referenced method is package-visible the high bit of the token item is one. In this case the class item must represent a reference to a class defined in this package.
The token item of the CONSTANT_SuperMethodref_info structure represents the virtual method token (§4.3.7.6) of the referenced method. Unlike in the CONSTANT_VirtualMethodref_info structure, the virtual method token is defined within the scope of the hierarchy of the superclass of the class indi-cated by the class item. If the referenced method is public or protected the
high bit of the token item is zero. If the referenced method is package-visible the high bit of the token item is one. In the latter case the class item must rep-resent a reference to a class defined in this package and at least one superclass of the class that contains a definition of the virtual method must also be defined in this package.
6.7.3 CONSTANT_StaticFieldref and CONSTANT_StaticMethodref
References to static fields and methods are represented by similar structures:
CONSTANT_StaticFieldref_info {
The items in these structures are as follows:
tag
The tag item of a CONSTANT_StaticFieldref_info structure has the value CONSTANT_StaticFieldref (5).
The tag item of a CONSTANT_StaticMethodref_info structure has the value CONSTANT_StaticMethodref (6).
static_field_ref and static_method_ref
The static_field_ref and static_method_ref item represents a reference to a static field or static method, respectively. Static method references include references to static methods, constructors, and private virtual methods.
If the referenced item is defined in this package the structure represents an internal_ref and the high bit of the structure is zero. If the referenced item is defined in another package the structure represents an external_ref and the high bit of the structure is one.
internal_ref
The internal_ref item represents a reference to a static field or method defined in this package. The items in the structure are:
padding
The padding item is equal to 0.
offset
The offset item of a CONSTANT_StaticFieldref_info structure represents a 16-bit offset into the Static Field Image defined by the Static Field component (§6.10) to this static field.
The offset item of a CONSTANT_StaticMethodref_info structure represents a 16-bit offset into the info item of the Method Component (§6.9) to a method_info structure. The method_info structure must represent the referenced method.
external_ref
The external_ref item represents a reference to a static field or method defined in an imported package. The items in the structure are:
package_token
The package_token item represents a package token (§4.3.7.1) defined in the Import Component (§6.6) of this CAP file. The value of this token must be a valid index into the packages table item of the import_component structure. The package represented at that index must be the imported pack-age.
The value of the package token must be between 0 and 127, inclusive.
The high bit of the package_token item is equal to one.
class_token
The class_token item represents the token (§4.3.7.2) of the class of the referenced class. It has the value of the class token of the class as defined in the Export file of the imported pack-age.
The class indicated by the class_token item must define the referenced field or method.
token
The token item of a CONSTANT_StaticFieldref_info struc-ture represents a static field token (§4.3.7.3) as defined in the Export file of the imported package. It has the value of the token of the referenced field.
The token item of a CONSTANT_StaticMethodref_info structure represents a static method token (§4.3.7.4) as defined in the Export file of the imported package. It has the value of the token of the referenced method.