使用 Class.isAnnotationPresent() 测试保留策略设置为 SOURCE 或 CLASS(默认值)的注解是否始终得到否定结果。 此错误很容易被忽视。
示例:
{
getClass().isAnnotationPresent(SourceAnnotation.class); //始终为 false
}
@Retention(RetentionPolicy.SOURCE)
@interface SourceAnnotation {}