Wednesday, April 27, 2011

Retention annotation in java

  1. @Retention indicates how long annotations whose annotated types are annotated
    @Retention are to be retained.
  2. The value of @Retention can be one of the members of the java.lang.annotation.
    RetentionPolicy enum:
  1. SOURCE. Annotations are to be discarded by the Java compiler.
  2. CLASS. Annotations are to be recorded in the class file but not be retained by the JVM.
    This is the default value.
  3. RUNTIME. Annotations are to be retained by the JVM so you can query them using reflection.

No comments:

Post a Comment

Chitika