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