Alex Rivera | Logout

Java Annotations - looking for an example of RetentionPolicy.CLASS

Asked 2010-10-03T11:44:12.783
33

according to Java Annotation API:

  • RetentionPolicy.CLASS Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time.

  • RetentionPolicy.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.

I am looking for a sample of "CLASS" retention policy. when we need to use this policy instead of RUNTIME policy.

Edit
Report

1 Answer

8

RetentionPolicy.CLASS are Useful when doing byte code-level post-processing.

Example:

answered 2013-06-28T11:38:16.417

Your Answer