NonRuntimeAnnotation.java 文件源码

java
阅读 37 收藏 0 点赞 0 评论 0

项目:error-prone-aspirator 作者:
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
  if (!methodSelect(
      instanceMethod(Matchers.<ExpressionTree>isSubtypeOf("java.lang.Class"), "getAnnotation"))
      .matches(tree, state)) {
    return Description.NO_MATCH;
  }
  MemberSelectTree memTree = (MemberSelectTree) tree.getArguments().get(0);
  TypeSymbol annotation = ASTHelpers.getSymbol(memTree.getExpression()).type.tsym;

  Retention retention = ASTHelpers.getAnnotation(annotation, Retention.class);
  if (retention != null && retention.value().equals(RUNTIME)) {
    return Description.NO_MATCH;
  }

  return describeMatch(tree, new SuggestedFix().replace(tree, "null"));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号