---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 27 Edition"
java_version: 27
chapter: "Chapter 9. Interfaces"
section: "9.6.2"
heading: "9.6.2. Defaults for Annotation Interface Elements"
parent: "9.6. Annotation Interfaces"
source: https://docs.oracle.com/javase/specs/jls/se27/html/jls-9.html#jls-9.6.2
id: "9.6.2"
url: https://jvm.obfuscated.software/jls/se27/9.6.2.html
raw: https://jvm.obfuscated.software/jls/se27/9.6.2.md
---

# 9.6.2. Defaults for Annotation Interface Elements

An annotation interface element may have a *default value*, specified by attaching the keyword `default` and a value to the method declaration which defines the element.

```
DefaultValue:
  default ElementValue
```

The following productions from [§9.7.1](9.7.1.md) are shown here for convenience:

```
ElementValue:
  ConditionalExpression
  ElementValueArrayInitializer
  Annotation

ElementValueArrayInitializer:
  { [ElementValueList] [,] }

ElementValueList:
  ElementValue {, ElementValue}
```

Note that an annotation interface element which is specified to have a default value is not a default method ([§9.4](9.4.md)). The declaration of an annotation interface cannot declare default methods ([§9.6.1](9.6.1.md)).

It is a compile-time error if the type of the element is not commensurate ([§9.7](9.7.md)) with the default value specified.

Default values are not compiled into annotations, but rather applied dynamically at the time annotations are read. Thus, changing a default value affects annotations even in classes that were compiled before the change was made (presuming these annotations lack an explicit value for the defaulted element).

**Example 9.6.2-1. Annotation Interface Declaration With Default Values**

Here is a refinement of the `RequestForEnhancement` annotation interface from [§9.6.1](9.6.1.md):

```
@interface RequestForEnhancement {
    int    id();       // No default - must be specified in
                       // each annotation
    String synopsis(); // No default - must be specified in
                       // each annotation
    String engineer()  default "[unassigned]";
    String date()      default "[unimplemented]";
}
```
