Definition

Java annotations

Java annotations are a method of associating metadata with program elements, enabling the extraction of program behaviors from annotations and the generation of interdependent code by the Java compiler or VM. This type of annotation-based development has been available since Java SKD 5.0.

Within the Java development kit (JDK), there are simple annotations used to make comments on code, as well as meta-annotations that can be used to create annotations within annotation-type declarations. While simple annotations can be used to make comments on code and its use, meta-annotations can describe how an annotation itself may be used and where.

Annotation type definitions are noted by the at sign (@), followed by an interface and the annotation name. Annotations themselves are shown as @ along with the annotation type. At compile time, annotation processor plug-ins can process the code within annotations to extract behaviors that create extra messages, source files and other resources, all of which then themselves may be compiled and processed.

 The Java compiler itself reserves a special set of annotations for syntax-related purposes, including @Deprecated, @Override and @SurpressWarnings.

This was last updated in July 2016

Continue Reading About Java annotations

Dig Deeper on Development tools for continuous software delivery

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close