Fields, methods, and interface methods are represented by similar structures:
CONSTANT_Fieldref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
CONSTANT_Methodref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
CONSTANT_InterfaceMethodref_info {
u1 tag;
u2 class_index;
u2 name_and_type_index;
}
The items of these structures are as follows:
-
tag
The
tagitem of aCONSTANT_Fieldref_infostructure has the valueCONSTANT_Fieldref(9).The
tagitem of aCONSTANT_Methodref_infostructure has the valueCONSTANT_Methodref(10).The
tagitem of aCONSTANT_InterfaceMethodref_infostructure has the valueCONSTANT_InterfaceMethodref(11). -
class_index
The value of the
class_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Class_infostructure (§4.4.1) representing a class or interface type that has the field or method as a member.In a
CONSTANT_Fieldref_infostructure, theclass_indexitem may be either a class type or an interface type.In a
CONSTANT_Methodref_infostructure, theclass_indexitem must be a class type, not an interface type.In a
CONSTANT_InterfaceMethodref_infostructure, theclass_indexitem must be an interface type, not a class type. -
name_and_type_index
The value of the
name_and_type_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_NameAndType_infostructure (§4.4.6). Thisconstant_poolentry indicates the name and descriptor of the field or method.In a
CONSTANT_Fieldref_infostructure, the indicated descriptor must be a field descriptor (§4.3.2). Otherwise, the indicated descriptor must be a method descriptor (§4.3.3).If the name of the method in a
CONSTANT_Methodref_infostructure begins with a '<' ('\u003c'), then the name must be the special name<init>, representing an instance initialization method (§2.9.1). The return type of such a method must bevoid.