Definition

Java annotations

Contributor(s): Matthew Haughn

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 Java Development Tools

PRO+

Content

Find more PRO+ content and other member only offers, here.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

Nice article. I wish more developer put comments in their code in tricky logic sections. It may help other decipher what their intent was.
Cancel

-ADS BY GOOGLE

File Extensions and File Formats

Powered by:

SearchCloudApplications

SearchSoftwareQuality

SearchFinancialApplications

SearchSAP

SearchManufacturingERP

Close