Signature attribute

The generic type that the descriptor erases: a field declared List<String> has the descriptor Ljava/util/List; and the signature Ljava/util/List<Ljava/lang/String;>;.

Appears on
class, field, method, record component
Since
class file 49.0 (Java 5)
javac writes it
for every declaration whose type involves generics
Needed by the JVM
no: it is for the class libraries (reflection), compilers or tools

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "Signature"
u4attribute_lengthbytes after this field
u2signature_indexa Utf8 generic signature

What it is for

The generic type that the descriptor erases: a field declared List<String> has the descriptor Ljava/util/List; and the signature Ljava/util/List<Ljava/lang/String;>;. The JVM never looks at it; reflection (getGenericType) and compilers do.

This is how a library jar keeps its generics for the code compiled against it, even though the bytecode itself is erased.

How common it is

JDK 25.0.5's java.base has 14,866 Signature attributes, in 3,343 of its 7,391 classes (10,590 on methods, 1,884 on classs, 2,312 on fields, 80 on record components).

A real one, byte by byte

From Boxing.class (compiled by javac 25), on method sum:

OffsetBytesFieldValue
11008 bytesSignature
110000 3aattribute_name_index#58
110200 00 00 02attribute_length2
110600 3bsignature_index#59

Open in the viewer

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