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

# 9.6.2. Defaults for Annotation Type Elements

An annotation type element may have a *default value*, specified by following the element's (empty) parameter list with the keyword `default` and an *ElementValue* ([§9.7.1](9.7.1.md)).

```
DefaultValue:
  default ElementValue
```

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 Type Declaration With Default Values**

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

```
@interface RequestForEnhancementDefault {
    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]";
}
```
