在Java中@Retention注解的源代码中,@Retention在其自身定义中使用,这是怎么可能的。
即使RetentionPolicy被设置为RUNTIME,那么在它还没有准备好运行之前,它如何能够被执行。
即使RetentionPolicy被设置为RUNTIME,那么在它还没有准备好运行之前,它如何能够被执行。
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();
}
@Target
,它具有@Target(value=ANNOTATION_TYPE)
。+1。我感到害怕并在谷歌上搜索了这个问题,最终来到了这里。 - user2453382