---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 11 Edition"
java_version: 11
chapter: "Chapter 4. The class File Format"
section: "4.7.22"
heading: "4.7.22. The AnnotationDefault Attribute"
parent: "4.7. Attributes"
source: https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.22
id: "4.7.22"
url: https://jvm.obfuscated.software/jvms/se11/4.7.22.html
raw: https://jvm.obfuscated.software/jvms/se11/4.7.22.md
---

# 4.7.22. The `AnnotationDefault` Attribute

The `AnnotationDefault` attribute is a variable-length attribute in the `attributes` table of certain `method_info` structures ([§4.6](4.6.md)), namely those representing elements of annotation types (JLS §9.6.1). The `AnnotationDefault` attribute records the default value (JLS §9.6.2) for the element represented by the `method_info` structure.

There may be at most one `AnnotationDefault` attribute in the `attributes` table of a `method_info` structure which represents an element of an annotation type.

The `AnnotationDefault` attribute has the following format:

```
AnnotationDefault_attribute {
    u2            attribute_name_index;
    u4            attribute_length;
    element_value default_value;
}
```

The items of the `AnnotationDefault_attribute` structure are as follows:

- **attribute_name_index**

  The value of the `attribute_name_index` item must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_Utf8_info` structure ([§4.4.7](4.4.7.md)) representing the string "`AnnotationDefault`".

- **attribute_length**

  The value of the `attribute_length` item indicates the length of the attribute, excluding the initial six bytes.

- **default_value**

  The `default_value` item represents the default value of the annotation type element represented by the `method_info` structure enclosing this `AnnotationDefault` attribute.
