前言
- 指示带注释类型的注释将保留多长时间。
- 如果注释类型声明上没有保留注释,则保留策略默认为{@code RetentionPolicy.CLASS}。
- 仅当元注释类型直接用于注释时,保留元注释才有效。
- 如果将元注释类型用作另一注释类型的成员类型,则无效。
源码
package java.lang.annotation;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Retention {
/**
* Returns the retention policy.
* @return the retention policy
*/
RetentionPolicy value();
}