I am trying to understand the retention policy from Java 1.5. But not getting a clear picture.
As per JavaDoc,
CLASS
- Annotations are to be recorded in the class file by the
compiler but need not be retained by the VM at run time.RUNTIME
- Annotations are to be recorded in the class file by the
compiler and retained by the VM at run time,so they may be read
reflectively.SOURCE
- Annotations are to be discarded by the compilerSOURCE
annotations are only present in the source file.
When the compiler "discards" the annotation, it is essentially ignoring that the annotation even exists. Source annotations basically serve the same purpose as commenting code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With