@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public void visit(Expression expr, MethodContext mc, DeclaredAnnotations da) {
if (expr.getCode() == AstCode.InvokeVirtual && expr.getArguments().size() == 2) {
MethodReference mr = (MethodReference) expr.getOperand();
if ((mr.getDeclaringType().getInternalName().startsWith("java/lang/reflect/") || mr.getDeclaringType()
.getInternalName().equals("java/lang/Class")) && mr.getName().contains("Annotation")) {
Object constant = Nodes.getConstant(expr.getArguments().get(1));
if (constant instanceof TypeReference) {
TypeReference tr = (TypeReference) constant;
DeclaredAnnotation annot = da.get(tr);
if (annot != null && annot.getPolicy() != RetentionPolicy.RUNTIME) {
mc.report("AnnotationNoRuntimeRetention", 0, expr, ANNOTATION.create(tr));
}
}
}
}
}
NoRuntimeRetention.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:huntbugs
作者:
评论列表
文章目录