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
| Type | Field | What it holds |
|---|---|---|
u2 | attribute_name_index | a Utf8: "AnnotationDefault" |
u4 | attribute_length | bytes after this field |
element_value | default_value | the 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:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 389 | 9 bytes | AnnotationDefault | |
| 389 | 00 09 | attribute_name_index | #9 |
| 391 | 00 00 00 03 | attribute_length | 3 |
| 395 | 3 bytes | element_value | |
| 395 | 73 | tag | 's' |
| 396 | 00 0a | const_value_index | #10 |
Specification: JVMS §4.7, The AnnotationDefault Attribute (Java SE 25).