The constants declared by the enumerated type specify the possible retention values for an @Retention meta-annotation. Annotations with SOURCE retention appear in Java source code only and are discarded by the compiler. Annotations with CLASS retention are compiled into the class file and are visible to tools that read class files but are not loaded by the Java VM at runtime. (This is the default retention for annotation types that do not have an @Retention meta-annotation.) Finally, annotations with RUNTIME retention are stored in the class file and loaded by the Java interpreter at runtime. These annotations are available for reflective access through java.lang.reflect.AnnotatedElement . Figure 10-81. java.lang.annotation.RetentionPolicypublic enum RetentionPolicy { // Enumerated Constants SOURCE , CLASS , RUNTIME ; // Public Class Methods public static RetentionPolicy valueOf (String name ); public static final RetentionPolicy[ ] values ( ); } Returned ByRetention.value( ) |