Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Help Java A Annotations

Related Tutorials


 
 

Share on Google+Share on Google+

Annotations

Advertisement
Annotations in computer programming languages provide data about a program that is not part of the program itself by decorating them.

Annotations

     

Annotations in computer programming languages provide data about a program that is not part of the program itself by decorating them. They does not impact directly to the operation of the code to which they annotate.

Annotations are mainly used for:

  • Information for the compiler: Compiler uses the annotations to detect errors or suppress warnings.
  • Compiler-time and deployment time processing: annotation information is processed by the annotation processor in order to produce new source code and other files.
  • Runtime processing: some annotations are scanned at runtime by using various techniques and open source libraries.

We can apply annotations to a program's declarations of classes, fields, methods, and other program elements. Rather than directly affecting on the program's semantic, they do affect the way programs are treated by tools and libraries, that can affect the semantics of an executing program. We can read the annotations from the class file, source files, or at run time.

Annotations are processed by compiler plug-ins called annotation processors whenever java source code is compiled. Processors are capable of producing  informational messages, create additional Java source files or resources which in turn may be compiled and processed. But processors cannot modify the annotated code itself. The Java compiler stores annotation metadata in the class files only when the annotation has a RetentionPolicy of CLASS or RUNTIME, that is used to determine how to interact with the program elements or to change their behavior.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 3, 2006

Related Tutorials

Discuss: Annotations  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com