This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

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
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
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.

-Jeff-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
 
GeeCON Prague 2014
 
subject: Agile Java - what is retention ?