Skip to content

Most visited

Recently visited

navigation

RetentionPolicy

public final enum RetentionPolicy
extends Enum<RetentionPolicy>

java.lang.Object
   ↳ java.lang.Enum<java.lang.annotation.RetentionPolicy>
     ↳ java.lang.annotation.RetentionPolicy


Annotation retention policy. The constants of this enumerated type describe the various policies for retaining annotations. They are used in conjunction with the Retention meta-annotation type to specify how long annotations are to be retained.

Summary

Enum values

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. 

Public methods

static RetentionPolicy valueOf(String name)
static final RetentionPolicy[] values()

Inherited methods

From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum values

CLASS

Added in API level 1
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. This is the default behavior.

RUNTIME

Added in API level 1
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.

See also:

SOURCE

Added in API level 1
RetentionPolicy SOURCE

Annotations are to be discarded by the compiler.

Public methods

valueOf

Added in API level 1
RetentionPolicy valueOf (String name)

Parameters
name String
Returns
RetentionPolicy

values

Added in API level 1
RetentionPolicy[] values ()

Returns
RetentionPolicy[]
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.