Stay organized with collections
Save and categorize content based on your preferences.
RetentionPolicy
class RetentionPolicy
Known Direct Subclasses
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.
|
RetentionPolicy.SOURCE |
Annotations are to be discarded by the compiler.
|
|
Annotation retention policy. The constants of this enumerated class describe the various policies for retaining annotations. They are used in conjunction with the Retention
meta-annotation interface to specify how long annotations are to be retained.
Summary
Enum values |
Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time.
|
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.
|
Annotations are to be discarded by the compiler.
|
Enum values
CLASS
enum val CLASS : RetentionPolicy
Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. This is the default behavior.
RUNTIME
enum val RUNTIME : RetentionPolicy
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
enum val SOURCE : RetentionPolicy
Annotations are to be discarded by the compiler.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-02-08 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-02-08 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-02-08 UTC."]]