Java annotation: Difference between revisions

Content deleted Content added
Ogai (talk | contribs)
First definition more precise
changed sub headers; now without repeated mention of "java" and "annotation"; +1 new header ===Impact and perception=== to head "Pros" and "Cons" sections
Line 3:
Java annotations can be added to program elements such as classes, methods, fields, parameters, local variables, and packages. Unlike tags added to Java documentation and processed with tools such as [[XDoclet]], Java annotations are completely accessible to the programmer while the software is running using [[reflection (programming)|reflection]].
 
==History of Java annotation==
Java annotations were introduced to the [[Java Community Process]] as JSR-175 in [[2002]] and approved in September [[2004]]. Annotations became available with the [[JDK]] version 1.5. The feature was added to the Java language through the specification.
 
==Processing==
==How Java annotations are processed==
When Java source code is compiled, the Java compiler stores annotation metadata in the class files. Later, the [[JVM]] or other programs can look for the metadata to determine how to interact with the program elements or change their behavior.
 
==Syntax of annotation==
Declaring an annotation is a variation on tags that have been added to comment sections in the past.
 
Line 19:
In the above example both Retention and Target are examples of annotations.
 
==Impact and Perception==
==Pros of using Java annotations==
===Pros===
Annotations allow the programmer to declare in their source code how the software should behave. It is an example of how declarative programming constructs can be added to a procedural language.
===Cons===
 
==Cons of using Java annotations==
* Adding metadata to a run time causes additional memory overhead.
* There are few standards that dictate what metadata tags should be used