What happens behind @Retention in java 1.5

I am trying to understand storage policy with Java 1.5. But not getting a clear picture.

Like for JavaDoc ,

  • CLASS - Annotations must be written to the class file using the compiler, but there is no need to save the VM at runtime.
  • RUNTIME - Annotations must be written to the class file using the compiler and saved by the VM at runtime, so they can be read reflexively.
  • SOURCE - Annotations should be discarded by the compiler
 
  • what does it mean "dropped"?
  • Does it look like the class file does not have a specific annotated element in it, putting it in SOURCE?
+5
source share
3 answers

SOURCE annotations are present only in the source file.

"" , , . , .

+6

.

@Retention - , -: . , , .

, @Foo, @Retention(RetentionPolicy.SOURCE), @Foo ( ) , .class ( , @Foo, ).

, ( ).

+3

Java . , , , . , , RETAINED Java , , .

, . RUNTIME JVM .

0

All Articles