Monday, 9 April 2012

Java - Annotations - Reflection

A Metadata Facility for the Java Programming Language.

Built-in Annotations in Java:
             @Override
                          Essentially tells to the compiler that method must be an overridden method. If not, then the compilers can report them as errors
             @SuppressWarnings
             @Deprecated

User-defined Annotations:
             Things that we need to consider while creating user defined annotation is as follows. (the same will be used for all annotations)
             Target Annotation
                              @Target(ElementType.METHOD) (Constructor, Field, Type, etc)
              Retention Annotation
                             @Retention(RetentionPolicy.CLASS) (Source Code, Class file, Run-time)

Reflection:
               Information related to Annotation types using Reflection(java Reflection API) for any type of java elements like class, interface, method, variables, etc.

No comments:

Post a Comment