NestMembers attribute
On the nest host, the list of its nest members.
- Appears on
- class
- Since
- class file 55.0 (Java 11)
- javac writes it
- for top-level classes with nested classes
- Needed by the JVM
- yes: the JVM reads it to load, verify or run the class
Layout
| Type | Field | What it holds |
|---|---|---|
u2 | attribute_name_index | a Utf8: "NestMembers" |
u4 | attribute_length | bytes after this field |
u2 | number_of_classes | |
u2[…] | classes | Class entries |
What it is for
On the nest host, the list of its nest members. The JVM checks both sides: a class is a nestmate only if it names the host and the host names it back.
How common it is
JDK 25.0.5's java.base has 969 NestMembers attributes, in 969 of its 7,391 classes (969 on classs).
A real one, byte by byte
From Nestmates.class (compiled by javac 25), on the class:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 425 | 10 bytes | NestMembers | |
| 425 | 00 17 | attribute_name_index | #23 |
| 427 | 00 00 00 04 | attribute_length | 4 |
| 431 | 00 01 | number_of_classes | 1 |
| 433 | 00 18 | class | #24 |
Specification: JVMS §4.7, The NestMembers Attribute (Java SE 25).