jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Agile Java - what is retention ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Agile Java - what is retention ?" Watch "Agile Java - what is retention ?" New topic

Agile Java - what is retention ?

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, as mentioned in table of content, what is retention actually ?

thank you
Jeff Langr
Ranch Hand

Joined: May 14, 2003
Posts: 799
Greetings Alvin,

Thanks for the query. "Retention" is discussed in the chapter on annotations. When creating your own custom annotations, you can specify how long they should be retained (kept around). This retention period can be one of three enum values: RetentionPolicy.SOURCE, RetentionPolicy.CLASS (which is the default), or RetentionPolicy.RUNTIME.

You might use RetentionPolicy.SOURCE if you've created an annotation that only an IDE needs to use. For example, you might have an @Todo annotation that marks sections of code as needing more work. This annotation information gets discarded when the code is compiled.

RetentionPolicy.CLASS means the annotation is stored in the class file, but the VM can choose to discard it at runtime.

RetentionPolicy.RUNTIME means that the annotation sticks around in the class file and is available at runtime. Sun modified the reflection API to allow extracting this annotation information at runtime.


Books: Pragmatic Unit Testing in Java, Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
subject: Agile Java - what is retention ?
It's not a secret anymore!