---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 25 Edition"
java_version: 25
chapter: "Chapter 4. The class File Format"
section: "4.7.29"
heading: "4.7.29. The NestMembers Attribute"
parent: "4.7. Attributes"
source: https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.7.29
id: "4.7.29"
url: https://jvm.obfuscated.software/jvms/se25/4.7.29.html
raw: https://jvm.obfuscated.software/jvms/se25/4.7.29.md
---

# 4.7.29. The `NestMembers` Attribute

The `NestMembers` attribute is a variable-length attribute in the `attributes` table of a `ClassFile` structure ([§4.1](4.1.md)). 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](5.4.4.md)).

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_index` item must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_Utf8_info` structure ([§4.4.7](4.4.7.md)) representing the string "`NestMembers`".

- **attribute_length**

  The value of the `attribute_length` item indicates the length of the attribute, excluding the initial six bytes.

- **number_of_classes**

  The value of the `number_of_classes` item indicates the number of entries in the `classes` array.

- **classes[]**

  Each value in the `classes` array must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_Class_info` structure ([§4.4.1](4.4.1.md)) representing a class or interface which is a member of the nest hosted by the current class or interface.

  The `classes` array is consulted by access control ([§5.4.4](5.4.4.md)). It should consist of references to other classes and interfaces that are in the same run-time package and have `NestHost` attributes which reference the current class or interface. Array items that do not meet these criteria are ignored by access control.
