diff --git a/java/ql/test/library-tests/annotation-arrays/Test.java b/java/ql/test/library-tests/annotation-arrays/Test.java new file mode 100644 index 00000000000..d7e721d8ad2 --- /dev/null +++ b/java/ql/test/library-tests/annotation-arrays/Test.java @@ -0,0 +1,14 @@ +class Test { + + @interface CustomAnnotation { + String value(); + } + + @interface ArrayValues { + CustomAnnotation[] annotationValues(); + } + + @ArrayValues(annotationValues = @CustomAnnotation(value = "only")) private int fieldWithSingular; + @ArrayValues(annotationValues = {@CustomAnnotation(value = "val1"), @CustomAnnotation(value = "val2")}) private int fieldWithMultiple; + +} diff --git a/java/ql/test/library-tests/annotation-arrays/test.expected b/java/ql/test/library-tests/annotation-arrays/test.expected new file mode 100644 index 00000000000..cd7c8dc15cc --- /dev/null +++ b/java/ql/test/library-tests/annotation-arrays/test.expected @@ -0,0 +1,3 @@ +| Test.java:11:82:11:98 | fieldWithSingular | Test.java:11:3:11:68 | ArrayValues | Test.java:11:35:11:67 | {...} | Test.java:11:35:11:67 | CustomAnnotation | +| Test.java:12:119:12:135 | fieldWithMultiple | Test.java:12:3:12:105 | ArrayValues | Test.java:12:35:12:104 | {...} | Test.java:12:36:12:68 | CustomAnnotation | +| Test.java:12:119:12:135 | fieldWithMultiple | Test.java:12:3:12:105 | ArrayValues | Test.java:12:35:12:104 | {...} | Test.java:12:71:12:103 | CustomAnnotation | diff --git a/java/ql/test/library-tests/annotation-arrays/test.ql b/java/ql/test/library-tests/annotation-arrays/test.ql new file mode 100644 index 00000000000..4c0dfd89b7b --- /dev/null +++ b/java/ql/test/library-tests/annotation-arrays/test.ql @@ -0,0 +1,9 @@ +import java + +from Field f, Annotation ann, Expr value, Expr valueChild +where + f.getDeclaringType().fromSource() and + ann = f.getAnAnnotation() and + value = ann.getAValue() and + valueChild.getParent() = value +select f, ann, value, valueChild