The NestMembers attribute is a variable-length attribute in the attributes table of a ClassFile structure (§4.1). The NestMembers attribute records the classes and interfaces that are authorized to claim membership in the nest hosted by the current class or interface (§5.4.4).
There may be at most one NestMembers attribute in the attributes table of a ClassFile structure.
The attributes table of a ClassFile structure must not contain both a NestMembers attribute and a NestHost attribute.
This rule prevents a nest host from claiming membership in a different nest. It is implicitly a member of the nest that it hosts.
The NestMembers attribute has the following format:
NestMembers_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 number_of_classes;
u2 classes[number_of_classes];
}
The items of the NestMembers_attribute structure are as follows:
-
attribute_name_index
The value of the
attribute_name_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Utf8_infostructure (§4.4.7) representing the string "NestMembers". -
attribute_length
The value of the
attribute_lengthitem indicates the length of the attribute, excluding the initial six bytes. -
number_of_classes
The value of the
number_of_classesitem indicates the number of entries in theclassesarray. -
classes[]
Each value in the
classesarray 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 which is a member of the nest hosted by the current class or interface.The
classesarray is consulted by access control (§5.4.4). It should consist of references to other classes and interfaces that are in the same run-time package and haveNestHostattributes which reference the current class or interface. Array items that do not meet these criteria are ignored by access control.