Compiling information from the JVM and JLS specifications gives us the following picture:
Annotations meta-annotated with the
@Retention
whose value isRetentionPolicy.SOURCE
must not be present in the binary representation of the class or interface in which they appear, i.e. they are not to be recorded in the class file at all.Annotations with the
RetentionPolicy.CLASS
must be represented in the binary representation of the class or interface in which they appear, unless they annotate a local variable declaration. An annotation on a local variable declaration is never retained in the binary representation.So this is what the
RuntimeInvisibleAnnotations
attribute is designed for.They need not be retained by the VM at run time, unless the Java Virtual Machine has been instructed to retain these annotations via some implementation-specific mechanism such as a command line flag.
Annotations with the
RetentionPolicy.RUNTIME
are to be recorded in the class file by the compiler and must be available at run time via reflection libraries. This is for theRuntimeVisibleAnnotations
attribute.