AnnotationDefault attribute

The default value of an annotation interface's element: String value() default "none"; compiles to an abstract method with this attribute..

Appears on
method
Since
class file 49.0 (Java 5)
javac writes it
for annotation elements with a default
Needed by the JVM
no: it is for the class libraries (reflection), compilers or tools

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "AnnotationDefault"
u4attribute_lengthbytes after this field
element_valuedefault_valuethe default

What it is for

The default value of an annotation interface's element: String value() default "none"; compiles to an abstract method with this attribute.

How common it is

JDK 25.0.5's java.base has 6 AnnotationDefault attributes, in 4 of its 7,391 classes (6 on methods).

A real one, byte by byte

From Annotations$Info.class (compiled by javac 25), on method value:

OffsetBytesFieldValue
3899 bytesAnnotationDefault
38900 09attribute_name_index#9
39100 00 00 03attribute_length3
3953 byteselement_value
39573tag's'
39600 0aconst_value_index#10

Open in the viewer

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