From ee11307751167a37fd599855f5f9631bf26f2f1c Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 2 Aug 2024 16:02:35 +0100 Subject: [PATCH 1/3] Add test for ECJ compiling an enum with a constructor parameter annotation --- .../ExtractorInformation.expected | 17 +++++++++++++++++ .../ExtractorInformation.qlref | 1 + .../ecj-tolerate-enum-annotations/Test.java | 9 +++++++++ .../ecj-tolerate-enum-annotations/Test2.java | 2 ++ .../ecj-tolerate-enum-annotations/test.expected | 1 + .../java/ecj-tolerate-enum-annotations/test.py | 8 ++++++++ .../java/ecj-tolerate-enum-annotations/test.ql | 4 ++++ 7 files changed, 42 insertions(+) create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test.java create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test2.java create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.expected create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.py create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.ql diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected new file mode 100644 index 000000000000..b198bcf677ef --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected @@ -0,0 +1,17 @@ +| Annotation processors enabled: true | 1 | +| Number of calls with call target | 5 | +| Number of calls with missing call target | 0 | +| Number of expressions with known type | 21 | +| Number of expressions with unknown type | 0 | +| Number of files | 697 | +| Number of files with extension class | 692 | +| Number of files with extension java | 2 | +| Number of files with extension properties | 2 | +| Number of lines of code | 6 | +| Number of lines of code with extension java | 6 | +| Percentage of calls with call target | 100 | +| Percentage of expressions with known type | 100 | +| Total number of lines | 11 | +| Total number of lines with extension java | 11 | +| Used annotation processor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor | 1 | +| Used annotation processor: lombok.launch.AnnotationProcessorHider$ClaimingProcessor | 1 | diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref new file mode 100644 index 000000000000..ff57e78a9d7a --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref @@ -0,0 +1 @@ +Telemetry/ExtractorInformation.ql \ No newline at end of file diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test.java b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test.java new file mode 100644 index 000000000000..bf3acc181751 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test.java @@ -0,0 +1,9 @@ +public enum Test { + + A("A"), B("B"), C("C"); + + private Test(@Ann String x) { } + +} + +@interface Ann {} diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test2.java b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test2.java new file mode 100644 index 000000000000..a5aed7a1e278 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Test2.java @@ -0,0 +1,2 @@ + +public class Test2 { Test t; } diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.expected b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.expected new file mode 100644 index 000000000000..b648b5762fdb --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.expected @@ -0,0 +1 @@ +| Test.java:5:16:5:28 | x | Test.java:5:16:5:19 | Ann | diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.py b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.py new file mode 100644 index 000000000000..40313e2654a3 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.py @@ -0,0 +1,8 @@ +import urllib.request +from create_database_utils import * + +urllib.request.urlretrieve("https://repo1.maven.org/maven2/org/eclipse/jdt/ecj/3.38.0/ecj-3.38.0.jar", "ecj.jar") + +# This tests the case where ECJ emits a RuntimeIn/VisibleAnnotations attribute that isn't the same size as the corresponding method argument list, in particular due to forgetting to include the synthetic parameters added to explicit enumeration constructors. + +run_codeql_database_create(["java -cp ecj.jar org.eclipse.jdt.internal.compiler.batch.Main Test.java -d out -source 8", "java -cp ecj.jar org.eclipse.jdt.internal.compiler.batch.Main Test2.java -cp out -source 8"], lang="java") diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.ql b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.ql new file mode 100644 index 000000000000..836ccc7564f2 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/test.ql @@ -0,0 +1,4 @@ +import java + +from Parameter p +select p, p.getAnAnnotation() From 1ee87670c6435389e4a5109f70957845d5263373 Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 2 Aug 2024 16:46:56 +0100 Subject: [PATCH 2/3] Switch to measuring just diagnostics --- .../Diagnostics.expected | 0 .../Diagnostics.ql | 4 ++++ .../ExtractorInformation.expected | 17 ----------------- .../ExtractorInformation.qlref | 1 - 4 files changed, 4 insertions(+), 18 deletions(-) create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.expected create mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.ql delete mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected delete mode 100644 java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.expected b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.ql b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.ql new file mode 100644 index 000000000000..60ef9109b180 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/Diagnostics.ql @@ -0,0 +1,4 @@ +import semmle.code.java.Diagnostics + +from Diagnostic d +select d, d.getSeverity(), d.getMessage() diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected deleted file mode 100644 index b198bcf677ef..000000000000 --- a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.expected +++ /dev/null @@ -1,17 +0,0 @@ -| Annotation processors enabled: true | 1 | -| Number of calls with call target | 5 | -| Number of calls with missing call target | 0 | -| Number of expressions with known type | 21 | -| Number of expressions with unknown type | 0 | -| Number of files | 697 | -| Number of files with extension class | 692 | -| Number of files with extension java | 2 | -| Number of files with extension properties | 2 | -| Number of lines of code | 6 | -| Number of lines of code with extension java | 6 | -| Percentage of calls with call target | 100 | -| Percentage of expressions with known type | 100 | -| Total number of lines | 11 | -| Total number of lines with extension java | 11 | -| Used annotation processor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor | 1 | -| Used annotation processor: lombok.launch.AnnotationProcessorHider$ClaimingProcessor | 1 | diff --git a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref b/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref deleted file mode 100644 index ff57e78a9d7a..000000000000 --- a/java/ql/integration-tests/all-platforms/java/ecj-tolerate-enum-annotations/ExtractorInformation.qlref +++ /dev/null @@ -1 +0,0 @@ -Telemetry/ExtractorInformation.ql \ No newline at end of file From f8914238101519887e39993526a795e5bbb169db Mon Sep 17 00:00:00 2001 From: Chris Smowton Date: Fri, 2 Aug 2024 18:41:19 +0100 Subject: [PATCH 3/3] Run Maven integration tests sequentially due to conflicts over ~/.m2 --- .../force_sequential_test_execution | 1 + .../force_sequential_test_execution | 1 + .../buildless-maven-multimodule/force_sequential_test_execution | 1 + .../force_sequential_test_execution | 1 + .../java/buildless-maven/force_sequential_test_execution | 1 + .../java/buildless-proxy-maven/force_sequential_test_execution | 1 + .../force_sequential_test_execution | 1 + .../java/java-web-jsp/force_sequential_test_execution | 1 + .../java/maven-enforcer/force_sequential_test_execution | 1 + .../force_sequential_test_execution | 1 + .../maven-sample-large-xml-files/force_sequential_test_execution | 1 + .../maven-sample-small-xml-files/force_sequential_test_execution | 1 + .../maven-sample-xml-mode-all/force_sequential_test_execution | 1 + .../maven-sample-xml-mode-byname/force_sequential_test_execution | 1 + .../force_sequential_test_execution | 1 + .../maven-sample-xml-mode-smart/force_sequential_test_execution | 1 + .../java/maven-sample/force_sequential_test_execution | 1 + 17 files changed, 17 insertions(+) create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-dependency-different-repository/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-inherit-trust-store/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-maven-multimodule/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-maven-tolerate-unavailable-dependency/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-maven/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-proxy-maven/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/buildless-snapshot-repository/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/java-web-jsp/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-enforcer/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-extract-properties/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-large-xml-files/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-small-xml-files/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-all/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-byname/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-disabled/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-smart/force_sequential_test_execution create mode 100644 java/ql/integration-tests/all-platforms/java/maven-sample/force_sequential_test_execution diff --git a/java/ql/integration-tests/all-platforms/java/buildless-dependency-different-repository/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-dependency-different-repository/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-dependency-different-repository/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-inherit-trust-store/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-inherit-trust-store/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-inherit-trust-store/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-maven-multimodule/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-maven-multimodule/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-maven-multimodule/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-maven-tolerate-unavailable-dependency/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-maven-tolerate-unavailable-dependency/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-maven-tolerate-unavailable-dependency/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-maven/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-maven/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-maven/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-proxy-maven/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-proxy-maven/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-proxy-maven/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/buildless-snapshot-repository/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/buildless-snapshot-repository/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/buildless-snapshot-repository/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/java-web-jsp/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/java-web-jsp/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/java-web-jsp/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-enforcer/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-enforcer/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-enforcer/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-extract-properties/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-extract-properties/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-extract-properties/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-large-xml-files/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-large-xml-files/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-large-xml-files/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-small-xml-files/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-small-xml-files/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-small-xml-files/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-all/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-all/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-all/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-byname/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-byname/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-byname/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-disabled/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-disabled/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-disabled/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-smart/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-smart/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample-xml-mode-smart/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially diff --git a/java/ql/integration-tests/all-platforms/java/maven-sample/force_sequential_test_execution b/java/ql/integration-tests/all-platforms/java/maven-sample/force_sequential_test_execution new file mode 100644 index 000000000000..dd90439bca59 --- /dev/null +++ b/java/ql/integration-tests/all-platforms/java/maven-sample/force_sequential_test_execution @@ -0,0 +1 @@ +# Concurrent Maven processes using ~/.m2/repository is not safe, so this test must run sequentially