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

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "NestMembers"
u4attribute_lengthbytes after this field
u2number_of_classes
u2[…]classesClass 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:

OffsetBytesFieldValue
42510 bytesNestMembers
42500 17attribute_name_index#23
42700 00 00 04attribute_length4
43100 01number_of_classes1
43300 18class#24

Open in the viewer

Specification: JVMS §4.7, The NestMembers Attribute (Java SE 25).