From bc7821965385f90a93dfd5266ba5b8c315c31145 Mon Sep 17 00:00:00 2001 From: yh-semmle Date: Wed, 5 Dec 2018 17:46:38 -0500 Subject: [PATCH] Java: account for change to field annotation extraction --- java/ql/src/semmle/code/java/Annotation.qll | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/ql/src/semmle/code/java/Annotation.qll b/java/ql/src/semmle/code/java/Annotation.qll index 329ac702b76..4ca39a44d7c 100755 --- a/java/ql/src/semmle/code/java/Annotation.qll +++ b/java/ql/src/semmle/code/java/Annotation.qll @@ -24,7 +24,13 @@ class Annotation extends @annotation, Expr { predicate isTypeAnnotation() { this instanceof TypeAnnotation } /** Gets the element being annotated. */ - Element getAnnotatedElement() { this.getParent() = result } + Element getAnnotatedElement() { + this.getParent().(Field).getDeclaration().getAField() = result and + this.getCompilationUnit().fromSource() + or + not result.(Field).getCompilationUnit().fromSource() and + this.getParent() = result + } /** Gets the annotation type declaration for this annotation. */ override AnnotationType getType() { result = Expr.super.getType() } @@ -41,7 +47,7 @@ class Annotation extends @annotation, Expr { Expr getValue(string name) { filteredAnnotValue(this, this.getAnnotationElement(name), result) } /** Gets the element being annotated. */ - Element getTarget() { exprs(this, _, _, result, _) } + Element getTarget() { result = getAnnotatedElement() } override string toString() { result = this.getType().getName() }