Record attribute

The components of a record, in order, each with its own attributes (Signature, annotations).

Appears on
class
Since
class file 60.0 (Java 16)
javac writes it
for record classes
Needed by the JVM
no: it is for the class libraries (reflection), compilers or tools

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "Record"
u4attribute_lengthbytes after this field
u2components_count
record_component_info[…]componentsname_index, descriptor_index, attributes_count, attributes

What it is for

The components of a record, in order, each with its own attributes (Signature, annotations). Class.getRecordComponents() reads it; serialization uses it to construct records through their canonical constructor.

The JVM itself treats a record as an ordinary final class that extends java.lang.Record.

How common it is

JDK 25.0.5's java.base has 190 Record attributes, in 190 of its 7,391 classes (190 on classs).

A real one, byte by byte

From Point.class (compiled by javac 25), on the class:

OffsetBytesFieldValue
158020 bytesRecord
158000 3aattribute_name_index#58
158200 00 00 0eattribute_length14
158600 02components_count2
15886 bytescomponent 0x
158800 12name_index#18
159000 13descriptor_index#19
15922 bytesattributes0
159200 00attributes_count0
15946 bytescomponent 1y
159400 16name_index#22
159600 13descriptor_index#19
15982 bytesattributes0
159800 00attributes_count0

Open in the viewer

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