From 70ba99c31121897c44e31ec236df54474e523049 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 26 Sep 2023 13:43:00 +0700 Subject: [PATCH 01/29] Upgrade CI build to JDK 21 Signed-off-by: Alexander Kriegisch --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cd1d223d4..e9b7f5713 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: # Check for available Temurin releases on https://adoptium.net/releases.html - java: [ 11, 17, 20 ] + java: [ 11, 17, 21 ] runs-on: ubuntu-latest From ff92343e7ab763941180a66df5b956cb971098ff Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 26 Sep 2023 13:45:32 +0700 Subject: [PATCH 02/29] Bump JDT Core to 1.9.21-SNAPSHOT Signed-off-by: Alexander Kriegisch --- .../compiler/lookup/AjLookupEnvironment.java | 12 +++++++++--- pom.xml | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index e0123ee4a..a97f3fa8a 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -148,11 +148,17 @@ public void completeTypeBindings() { for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY, units[i].compilationResult.fileName); - units[i].scope.connectTypeHierarchy(); + units[i].scope.connectTypeHierarchy1(); CompilationAndWeavingContext.leavingPhase(tok); } - stepCompleted = CONNECT_TYPE_HIERARCHY; - + stepCompleted = CONNECT_TYPE_HIERARCHY1; + for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { + ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY, + units[i].compilationResult.fileName); + units[i].scope.connectTypeHierarchy2(); + CompilationAndWeavingContext.leavingPhase(tok); + } + stepCompleted = CONNECT_TYPE_HIERARCHY2; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS, units[i].compilationResult.fileName); diff --git a/pom.xml b/pom.xml index 8a9557dad..3ca99b8a6 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ true - 1.9.20 + 1.9.21-SNAPSHOT 9.5 1.6.3 2.6.2 From 1bd4f92c4c39d86344ea48a76dcd1c865fb0a043 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 27 Sep 2023 08:49:06 +0700 Subject: [PATCH 03/29] CI build: remove JDK 11 build, switch 21 to 21-ea Background: JDT Core dependencies now contain hundreds of Java 17 class files, i.e. Ajc now requires Java 17+ runtime environment. :-( For more details, see: https://github.com/eclipse-aspectj/aspectj/issues/260#issuecomment-1736540176 Adoptium Java 21 release is not available yet, so we need to run on EA. Signed-off-by: Alexander Kriegisch --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e9b7f5713..e8ab9505a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: # Check for available Temurin releases on https://adoptium.net/releases.html - java: [ 11, 17, 21 ] + java: [ 17, 21-ea ] runs-on: ubuntu-latest From 5988c287c7e7348c083847732408cb0b32441a6d Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 27 Sep 2023 09:10:47 +0700 Subject: [PATCH 04/29] Remove old '.cvsignore' files Signed-off-by: Alexander Kriegisch --- ajde.core/testdata/BuildCancelling/.cvsignore | 1 - ajde.core/testdata/coverage/.cvsignore | 1 - ajde.core/testdata/figures-coverage/.cvsignore | 1 - ajde.core/testdata/figures-coverage/figures/.cvsignore | 8 -------- .../figures-coverage/figures/composites/.cvsignore | 3 --- .../figures-coverage/figures/primitives/planar/.cvsignore | 4 ---- .../figures-coverage/figures/primitives/solid/.cvsignore | 1 - ajde/src/.cvsignore | 2 -- ajde/testdata/AspectJBuildManagerTest/.cvsignore | 2 -- ajde/testdata/LstBuildConfigManagerTest/.cvsignore | 2 -- ajde/testdata/StructureModelRegressionTest/.cvsignore | 2 -- ajde/testdata/StructureModelRegressionTest/pkg/.cvsignore | 1 - ajde/testdata/StructureViewManagerTest/.cvsignore | 1 - ajde/testdata/bug-83565/.cvsignore | 1 - ajde/testdata/examples/.cvsignore | 1 - ajde/testdata/examples/configs/.cvsignore | 1 - ajde/testdata/examples/coverage/.cvsignore | 1 - ajde/testdata/examples/declare-warning/.cvsignore | 1 - ajde/testdata/examples/figures-coverage/.cvsignore | 1 - .../testdata/examples/figures-coverage/figures/.cvsignore | 8 -------- .../figures-coverage/figures/composites/.cvsignore | 3 --- .../figures-coverage/figures/primitives/planar/.cvsignore | 4 ---- .../figures-coverage/figures/primitives/solid/.cvsignore | 1 - ajde/testdata/examples/figures-demo/.cvsignore | 1 - ajde/testdata/examples/spacewar/.cvsignore | 1 - ajde/testdata/examples/spacewar/spacewar/.cvsignore | 1 - ajde/testdata/figures-coverage/.cvsignore | 1 - ajde/testdata/figures-coverage/figures/.cvsignore | 8 -------- .../figures-coverage/figures/composites/.cvsignore | 3 --- .../figures-coverage/figures/primitives/planar/.cvsignore | 4 ---- .../figures-coverage/figures/primitives/solid/.cvsignore | 1 - ajde/testdata/inheritance/.cvsignore | 1 - ajdoc/testdata/bug82340/.cvsignore | 1 - ajdoc/testdata/coverage/.cvsignore | 1 - ajdoc/testdata/declareForms/.cvsignore | 1 - ajdoc/testdata/figures-demo/.cvsignore | 1 - ajdoc/testdata/patterns/.cvsignore | 1 - ajdoc/testdata/spacewar/.cvsignore | 1 - ajdoc/testdata/spacewar/spacewar/.cvsignore | 1 - asm/src/.cvsignore | 2 -- bridge/src/.cvsignore | 1 - docs/sandbox/aopalliance/.cvsignore | 1 - docs/teaching/exercises/.cvsignore | 1 - org.aspectj.ajdt.core/src/.cvsignore | 1 - org.aspectj.ajdt.core/testdata/src1/.cvsignore | 2 -- org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore | 1 - org.aspectj.matcher/src/.cvsignore | 2 -- testing-client/src/.cvsignore | 1 - testing-drivers/src/.cvsignore | 1 - testing-util/src/.cvsignore | 1 - testing/figures-coverage/.cvsignore | 1 - testing/figures-coverage/figures/.cvsignore | 8 -------- testing/figures-coverage/figures/composites/.cvsignore | 3 --- .../figures-coverage/figures/primitives/planar/.cvsignore | 4 ---- .../figures-coverage/figures/primitives/solid/.cvsignore | 1 - testing/src/.cvsignore | 1 - tests/new/.cvsignore | 1 - tests/profiling/.cvsignore | 4 ---- tests/src/.cvsignore | 1 - .../java/org/aspectj/systemtest/ajc150/tests/.cvsignore | 1 - .../src/test/java/org/aspectj/systemtest/tests/.cvsignore | 1 - .../org/aspectj/systemtest/ajc150/tests/.cvsignore | 1 - .../resources/org/aspectj/systemtest/tests/.cvsignore | 1 - util/src/.cvsignore | 1 - weaver/src/.cvsignore | 2 -- 65 files changed, 124 deletions(-) delete mode 100644 ajde.core/testdata/BuildCancelling/.cvsignore delete mode 100644 ajde.core/testdata/coverage/.cvsignore delete mode 100644 ajde.core/testdata/figures-coverage/.cvsignore delete mode 100644 ajde.core/testdata/figures-coverage/figures/.cvsignore delete mode 100644 ajde.core/testdata/figures-coverage/figures/composites/.cvsignore delete mode 100644 ajde.core/testdata/figures-coverage/figures/primitives/planar/.cvsignore delete mode 100644 ajde.core/testdata/figures-coverage/figures/primitives/solid/.cvsignore delete mode 100644 ajde/src/.cvsignore delete mode 100644 ajde/testdata/AspectJBuildManagerTest/.cvsignore delete mode 100644 ajde/testdata/LstBuildConfigManagerTest/.cvsignore delete mode 100644 ajde/testdata/StructureModelRegressionTest/.cvsignore delete mode 100644 ajde/testdata/StructureModelRegressionTest/pkg/.cvsignore delete mode 100644 ajde/testdata/StructureViewManagerTest/.cvsignore delete mode 100644 ajde/testdata/bug-83565/.cvsignore delete mode 100644 ajde/testdata/examples/.cvsignore delete mode 100644 ajde/testdata/examples/configs/.cvsignore delete mode 100644 ajde/testdata/examples/coverage/.cvsignore delete mode 100644 ajde/testdata/examples/declare-warning/.cvsignore delete mode 100644 ajde/testdata/examples/figures-coverage/.cvsignore delete mode 100644 ajde/testdata/examples/figures-coverage/figures/.cvsignore delete mode 100644 ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore delete mode 100644 ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore delete mode 100644 ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore delete mode 100644 ajde/testdata/examples/figures-demo/.cvsignore delete mode 100644 ajde/testdata/examples/spacewar/.cvsignore delete mode 100644 ajde/testdata/examples/spacewar/spacewar/.cvsignore delete mode 100644 ajde/testdata/figures-coverage/.cvsignore delete mode 100644 ajde/testdata/figures-coverage/figures/.cvsignore delete mode 100644 ajde/testdata/figures-coverage/figures/composites/.cvsignore delete mode 100644 ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore delete mode 100644 ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore delete mode 100644 ajde/testdata/inheritance/.cvsignore delete mode 100644 ajdoc/testdata/bug82340/.cvsignore delete mode 100644 ajdoc/testdata/coverage/.cvsignore delete mode 100644 ajdoc/testdata/declareForms/.cvsignore delete mode 100644 ajdoc/testdata/figures-demo/.cvsignore delete mode 100644 ajdoc/testdata/patterns/.cvsignore delete mode 100644 ajdoc/testdata/spacewar/.cvsignore delete mode 100644 ajdoc/testdata/spacewar/spacewar/.cvsignore delete mode 100644 asm/src/.cvsignore delete mode 100644 bridge/src/.cvsignore delete mode 100644 docs/sandbox/aopalliance/.cvsignore delete mode 100644 docs/teaching/exercises/.cvsignore delete mode 100644 org.aspectj.ajdt.core/src/.cvsignore delete mode 100644 org.aspectj.ajdt.core/testdata/src1/.cvsignore delete mode 100644 org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore delete mode 100644 org.aspectj.matcher/src/.cvsignore delete mode 100644 testing-client/src/.cvsignore delete mode 100644 testing-drivers/src/.cvsignore delete mode 100644 testing-util/src/.cvsignore delete mode 100644 testing/figures-coverage/.cvsignore delete mode 100644 testing/figures-coverage/figures/.cvsignore delete mode 100644 testing/figures-coverage/figures/composites/.cvsignore delete mode 100644 testing/figures-coverage/figures/primitives/planar/.cvsignore delete mode 100644 testing/figures-coverage/figures/primitives/solid/.cvsignore delete mode 100644 testing/src/.cvsignore delete mode 100644 tests/new/.cvsignore delete mode 100644 tests/profiling/.cvsignore delete mode 100644 tests/src/.cvsignore delete mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore delete mode 100644 tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore delete mode 100644 tests/src/test/resources/org/aspectj/systemtest/ajc150/tests/.cvsignore delete mode 100644 tests/src/test/resources/org/aspectj/systemtest/tests/.cvsignore delete mode 100644 util/src/.cvsignore delete mode 100644 weaver/src/.cvsignore diff --git a/ajde.core/testdata/BuildCancelling/.cvsignore b/ajde.core/testdata/BuildCancelling/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/ajde.core/testdata/BuildCancelling/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/ajde.core/testdata/coverage/.cvsignore b/ajde.core/testdata/coverage/.cvsignore deleted file mode 100644 index 17637b455..000000000 --- a/ajde.core/testdata/coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.ajsym diff --git a/ajde.core/testdata/figures-coverage/.cvsignore b/ajde.core/testdata/figures-coverage/.cvsignore deleted file mode 100644 index c6495af69..000000000 --- a/ajde.core/testdata/figures-coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -all.ajsym diff --git a/ajde.core/testdata/figures-coverage/figures/.cvsignore b/ajde.core/testdata/figures-coverage/figures/.cvsignore deleted file mode 100644 index 9a2b438e3..000000000 --- a/ajde.core/testdata/figures-coverage/figures/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Checks.class -Debug.class -Element.class -Figure.class -FigureElement.class -Main.class -Main$TestGUI.class -Test.class diff --git a/ajde.core/testdata/figures-coverage/figures/composites/.cvsignore b/ajde.core/testdata/figures-coverage/figures/composites/.cvsignore deleted file mode 100644 index d9011a888..000000000 --- a/ajde.core/testdata/figures-coverage/figures/composites/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -BoundedLine.class -Line.class -Square.class diff --git a/ajde.core/testdata/figures-coverage/figures/primitives/planar/.cvsignore b/ajde.core/testdata/figures-coverage/figures/primitives/planar/.cvsignore deleted file mode 100644 index 1dd78c3c0..000000000 --- a/ajde.core/testdata/figures-coverage/figures/primitives/planar/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -StrictlyBoundedPoint.class -PointBoundsException.class -Point.class -BoundedPoint.class diff --git a/ajde.core/testdata/figures-coverage/figures/primitives/solid/.cvsignore b/ajde.core/testdata/figures-coverage/figures/primitives/solid/.cvsignore deleted file mode 100644 index fd0572c5e..000000000 --- a/ajde.core/testdata/figures-coverage/figures/primitives/solid/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -SolidPoint.class diff --git a/ajde/src/.cvsignore b/ajde/src/.cvsignore deleted file mode 100644 index ff5587df8..000000000 --- a/ajde/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -ajde.lst -ajdeSrc.lst diff --git a/ajde/testdata/AspectJBuildManagerTest/.cvsignore b/ajde/testdata/AspectJBuildManagerTest/.cvsignore deleted file mode 100644 index 3be9773da..000000000 --- a/ajde/testdata/AspectJBuildManagerTest/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -empty.ajsym diff --git a/ajde/testdata/LstBuildConfigManagerTest/.cvsignore b/ajde/testdata/LstBuildConfigManagerTest/.cvsignore deleted file mode 100644 index 0029faaf6..000000000 --- a/ajde/testdata/LstBuildConfigManagerTest/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -configs.ajsym -*.ajsym diff --git a/ajde/testdata/StructureModelRegressionTest/.cvsignore b/ajde/testdata/StructureModelRegressionTest/.cvsignore deleted file mode 100644 index 7d07f7031..000000000 --- a/ajde/testdata/StructureModelRegressionTest/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -example.ajsym -bin diff --git a/ajde/testdata/StructureModelRegressionTest/pkg/.cvsignore b/ajde/testdata/StructureModelRegressionTest/pkg/.cvsignore deleted file mode 100644 index 14314ab36..000000000 --- a/ajde/testdata/StructureModelRegressionTest/pkg/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -example.ajsym diff --git a/ajde/testdata/StructureViewManagerTest/.cvsignore b/ajde/testdata/StructureViewManagerTest/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/ajde/testdata/StructureViewManagerTest/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/ajde/testdata/bug-83565/.cvsignore b/ajde/testdata/bug-83565/.cvsignore deleted file mode 100644 index 5e8d7b618..000000000 --- a/ajde/testdata/bug-83565/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -build.ajsym diff --git a/ajde/testdata/examples/.cvsignore b/ajde/testdata/examples/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/ajde/testdata/examples/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/ajde/testdata/examples/configs/.cvsignore b/ajde/testdata/examples/configs/.cvsignore deleted file mode 100644 index bd4e1a00b..000000000 --- a/ajde/testdata/examples/configs/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -configs.ajsym diff --git a/ajde/testdata/examples/coverage/.cvsignore b/ajde/testdata/examples/coverage/.cvsignore deleted file mode 100644 index 17637b455..000000000 --- a/ajde/testdata/examples/coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.ajsym diff --git a/ajde/testdata/examples/declare-warning/.cvsignore b/ajde/testdata/examples/declare-warning/.cvsignore deleted file mode 100644 index 17637b455..000000000 --- a/ajde/testdata/examples/declare-warning/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.ajsym diff --git a/ajde/testdata/examples/figures-coverage/.cvsignore b/ajde/testdata/examples/figures-coverage/.cvsignore deleted file mode 100644 index c6495af69..000000000 --- a/ajde/testdata/examples/figures-coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -all.ajsym diff --git a/ajde/testdata/examples/figures-coverage/figures/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/.cvsignore deleted file mode 100644 index 9a2b438e3..000000000 --- a/ajde/testdata/examples/figures-coverage/figures/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Checks.class -Debug.class -Element.class -Figure.class -FigureElement.class -Main.class -Main$TestGUI.class -Test.class diff --git a/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore deleted file mode 100644 index d9011a888..000000000 --- a/ajde/testdata/examples/figures-coverage/figures/composites/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -BoundedLine.class -Line.class -Square.class diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore deleted file mode 100644 index 1dd78c3c0..000000000 --- a/ajde/testdata/examples/figures-coverage/figures/primitives/planar/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -StrictlyBoundedPoint.class -PointBoundsException.class -Point.class -BoundedPoint.class diff --git a/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore b/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore deleted file mode 100644 index fd0572c5e..000000000 --- a/ajde/testdata/examples/figures-coverage/figures/primitives/solid/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -SolidPoint.class diff --git a/ajde/testdata/examples/figures-demo/.cvsignore b/ajde/testdata/examples/figures-demo/.cvsignore deleted file mode 100644 index ad69a1aa9..000000000 --- a/ajde/testdata/examples/figures-demo/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -figures-demo-all.ajsym diff --git a/ajde/testdata/examples/spacewar/.cvsignore b/ajde/testdata/examples/spacewar/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/ajde/testdata/examples/spacewar/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/ajde/testdata/examples/spacewar/spacewar/.cvsignore b/ajde/testdata/examples/spacewar/spacewar/.cvsignore deleted file mode 100644 index 17637b455..000000000 --- a/ajde/testdata/examples/spacewar/spacewar/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.ajsym diff --git a/ajde/testdata/figures-coverage/.cvsignore b/ajde/testdata/figures-coverage/.cvsignore deleted file mode 100644 index c6495af69..000000000 --- a/ajde/testdata/figures-coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -all.ajsym diff --git a/ajde/testdata/figures-coverage/figures/.cvsignore b/ajde/testdata/figures-coverage/figures/.cvsignore deleted file mode 100644 index 9a2b438e3..000000000 --- a/ajde/testdata/figures-coverage/figures/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Checks.class -Debug.class -Element.class -Figure.class -FigureElement.class -Main.class -Main$TestGUI.class -Test.class diff --git a/ajde/testdata/figures-coverage/figures/composites/.cvsignore b/ajde/testdata/figures-coverage/figures/composites/.cvsignore deleted file mode 100644 index d9011a888..000000000 --- a/ajde/testdata/figures-coverage/figures/composites/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -BoundedLine.class -Line.class -Square.class diff --git a/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore b/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore deleted file mode 100644 index 1dd78c3c0..000000000 --- a/ajde/testdata/figures-coverage/figures/primitives/planar/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -StrictlyBoundedPoint.class -PointBoundsException.class -Point.class -BoundedPoint.class diff --git a/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore b/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore deleted file mode 100644 index fd0572c5e..000000000 --- a/ajde/testdata/figures-coverage/figures/primitives/solid/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -SolidPoint.class diff --git a/ajde/testdata/inheritance/.cvsignore b/ajde/testdata/inheritance/.cvsignore deleted file mode 100644 index a5f90a68e..000000000 --- a/ajde/testdata/inheritance/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -inheritance.ajsym diff --git a/ajdoc/testdata/bug82340/.cvsignore b/ajdoc/testdata/bug82340/.cvsignore deleted file mode 100644 index 8e695ec83..000000000 --- a/ajdoc/testdata/bug82340/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc diff --git a/ajdoc/testdata/coverage/.cvsignore b/ajdoc/testdata/coverage/.cvsignore deleted file mode 100644 index 8e695ec83..000000000 --- a/ajdoc/testdata/coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc diff --git a/ajdoc/testdata/declareForms/.cvsignore b/ajdoc/testdata/declareForms/.cvsignore deleted file mode 100644 index 8e695ec83..000000000 --- a/ajdoc/testdata/declareForms/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc diff --git a/ajdoc/testdata/figures-demo/.cvsignore b/ajdoc/testdata/figures-demo/.cvsignore deleted file mode 100644 index ad69a1aa9..000000000 --- a/ajdoc/testdata/figures-demo/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -figures-demo-all.ajsym diff --git a/ajdoc/testdata/patterns/.cvsignore b/ajdoc/testdata/patterns/.cvsignore deleted file mode 100644 index 8e695ec83..000000000 --- a/ajdoc/testdata/patterns/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -doc diff --git a/ajdoc/testdata/spacewar/.cvsignore b/ajdoc/testdata/spacewar/.cvsignore deleted file mode 100644 index e9f81f44b..000000000 --- a/ajdoc/testdata/spacewar/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -docdir diff --git a/ajdoc/testdata/spacewar/spacewar/.cvsignore b/ajdoc/testdata/spacewar/spacewar/.cvsignore deleted file mode 100644 index 17637b455..000000000 --- a/ajdoc/testdata/spacewar/spacewar/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.ajsym diff --git a/asm/src/.cvsignore b/asm/src/.cvsignore deleted file mode 100644 index edd86b356..000000000 --- a/asm/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -asm.lst -asmSrc.lst diff --git a/bridge/src/.cvsignore b/bridge/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/bridge/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/docs/sandbox/aopalliance/.cvsignore b/docs/sandbox/aopalliance/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/docs/sandbox/aopalliance/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/docs/teaching/exercises/.cvsignore b/docs/teaching/exercises/.cvsignore deleted file mode 100644 index d6be13d96..000000000 --- a/docs/teaching/exercises/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -burn diff --git a/org.aspectj.ajdt.core/src/.cvsignore b/org.aspectj.ajdt.core/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/org.aspectj.ajdt.core/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/org.aspectj.ajdt.core/testdata/src1/.cvsignore b/org.aspectj.ajdt.core/testdata/src1/.cvsignore deleted file mode 100644 index c06bd3c77..000000000 --- a/org.aspectj.ajdt.core/testdata/src1/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.class diff --git a/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore b/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore deleted file mode 100644 index 6b468b62a..000000000 --- a/org.aspectj.ajdt.core/testdata/src1/p1/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.class diff --git a/org.aspectj.matcher/src/.cvsignore b/org.aspectj.matcher/src/.cvsignore deleted file mode 100644 index defacf099..000000000 --- a/org.aspectj.matcher/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bcweaver.lst -bcweaverSrc.lst diff --git a/testing-client/src/.cvsignore b/testing-client/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/testing-client/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/testing-drivers/src/.cvsignore b/testing-drivers/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/testing-drivers/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/testing-util/src/.cvsignore b/testing-util/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/testing-util/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/testing/figures-coverage/.cvsignore b/testing/figures-coverage/.cvsignore deleted file mode 100644 index c6495af69..000000000 --- a/testing/figures-coverage/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -all.ajsym diff --git a/testing/figures-coverage/figures/.cvsignore b/testing/figures-coverage/figures/.cvsignore deleted file mode 100644 index 9a2b438e3..000000000 --- a/testing/figures-coverage/figures/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Checks.class -Debug.class -Element.class -Figure.class -FigureElement.class -Main.class -Main$TestGUI.class -Test.class diff --git a/testing/figures-coverage/figures/composites/.cvsignore b/testing/figures-coverage/figures/composites/.cvsignore deleted file mode 100644 index d9011a888..000000000 --- a/testing/figures-coverage/figures/composites/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -BoundedLine.class -Line.class -Square.class diff --git a/testing/figures-coverage/figures/primitives/planar/.cvsignore b/testing/figures-coverage/figures/primitives/planar/.cvsignore deleted file mode 100644 index 1dd78c3c0..000000000 --- a/testing/figures-coverage/figures/primitives/planar/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -StrictlyBoundedPoint.class -PointBoundsException.class -Point.class -BoundedPoint.class diff --git a/testing/figures-coverage/figures/primitives/solid/.cvsignore b/testing/figures-coverage/figures/primitives/solid/.cvsignore deleted file mode 100644 index fd0572c5e..000000000 --- a/testing/figures-coverage/figures/primitives/solid/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -SolidPoint.class diff --git a/testing/src/.cvsignore b/testing/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/testing/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/tests/new/.cvsignore b/tests/new/.cvsignore deleted file mode 100644 index 168aa3113..000000000 --- a/tests/new/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -ajworkingdir diff --git a/tests/profiling/.cvsignore b/tests/profiling/.cvsignore deleted file mode 100644 index 189c180cf..000000000 --- a/tests/profiling/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -results -gc.txt -java.hprof.txt -project.properties diff --git a/tests/src/.cvsignore b/tests/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/tests/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore b/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore deleted file mode 100644 index 9d3c17f8d..000000000 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -ajcTestSuite.dtd diff --git a/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore b/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore deleted file mode 100644 index 9d3c17f8d..000000000 --- a/tests/src/test/java/org/aspectj/systemtest/tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -ajcTestSuite.dtd diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc150/tests/.cvsignore b/tests/src/test/resources/org/aspectj/systemtest/ajc150/tests/.cvsignore deleted file mode 100644 index 9d3c17f8d..000000000 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc150/tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -ajcTestSuite.dtd diff --git a/tests/src/test/resources/org/aspectj/systemtest/tests/.cvsignore b/tests/src/test/resources/org/aspectj/systemtest/tests/.cvsignore deleted file mode 100644 index 9d3c17f8d..000000000 --- a/tests/src/test/resources/org/aspectj/systemtest/tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -ajcTestSuite.dtd diff --git a/util/src/.cvsignore b/util/src/.cvsignore deleted file mode 100644 index a3f0b1b77..000000000 --- a/util/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/weaver/src/.cvsignore b/weaver/src/.cvsignore deleted file mode 100644 index defacf099..000000000 --- a/weaver/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bcweaver.lst -bcweaverSrc.lst From e39b13fccc0b6898b90441ffc2759239e1502a37 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 27 Sep 2023 09:13:11 +0700 Subject: [PATCH 05/29] Ignore AspectJ core dumps Signed-off-by: Alexander Kriegisch --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d0b7450be..a55fb9601 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,9 @@ bin/ /lib/regexp/ /lib/saxon/ +# AspectJ core dumps +ajcore.*.txt + # When using a RAM disk to speed up development, see how-to in docs/developer/ram-disk/settings-ramdisk.xml /.mvn/maven.config /.mvn/settings-ramdisk.xml From 319e153eeddbeae9133ed5af28da1b85f638cda2 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 28 Sep 2023 10:51:38 +0700 Subject: [PATCH 06/29] AjLookupEnvironment: add new phase CONNECT_TYPE_HIERARCHY2 Signed-off-by: Alexander Kriegisch --- .../context/CompilationAndWeavingContext.java | 29 ++++++++++--------- .../compiler/lookup/AjLookupEnvironment.java | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java index bfb8ec190..451c9cca7 100644 --- a/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java +++ b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java @@ -41,7 +41,7 @@ public class CompilationAndWeavingContext { public static final int COMPLETING_TYPE_BINDINGS = 6; public static final int PROCESSING_DECLARE_PARENTS = 7; public static final int CHECK_AND_SET_IMPORTS = 8; - public static final int CONNECTING_TYPE_HIERARCHY = 9; + public static final int CONNECTING_TYPE_HIERARCHY1 = 9; public static final int BUILDING_FIELDS_AND_METHODS = 10; public static final int COLLECTING_ITDS_AND_DECLARES = 11; public static final int PROCESSING_DECLARE_ANNOTATIONS = 12; @@ -54,31 +54,32 @@ public class CompilationAndWeavingContext { public static final int FIXING_SUPER_CALLS_IN_ITDS = 19; public static final int FIXING_SUPER_CALLS = 20; public static final int OPTIMIZING_THIS_JOIN_POINT_CALLS = 21; + public static final int CONNECTING_TYPE_HIERARCHY2 = 22; // "BACK END" - public static final int WEAVING = 22; - public static final int PROCESSING_REWEAVABLE_STATE = 23; - public static final int PROCESSING_TYPE_MUNGERS = 24; - public static final int WEAVING_ASPECTS = 25; - public static final int WEAVING_CLASSES = 26; - public static final int WEAVING_TYPE = 27; - public static final int MATCHING_SHADOW = 28; - public static final int IMPLEMENTING_ON_SHADOW = 29; - public static final int MATCHING_POINTCUT = 30; - public static final int MUNGING_WITH = 31; - public static final int PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY = 32; + public static final int WEAVING = 23; + public static final int PROCESSING_REWEAVABLE_STATE = 24; + public static final int PROCESSING_TYPE_MUNGERS = 25; + public static final int WEAVING_ASPECTS = 26; + public static final int WEAVING_CLASSES = 27; + public static final int WEAVING_TYPE = 28; + public static final int MATCHING_SHADOW = 29; + public static final int IMPLEMENTING_ON_SHADOW = 30; + public static final int MATCHING_POINTCUT = 31; + public static final int MUNGING_WITH = 32; + public static final int PROCESSING_ATASPECTJTYPE_MUNGERS_ONLY = 33; // phase names public static final String[] PHASE_NAMES = new String[] { "batch building", "incrementally building", "processing compilation unit", "resolving types defined in compilation unit", "analysing types defined in compilation unit", "generating unwoven code for type defined in compilation unit", - "completing type bindings", "processing declare parents", "checking and setting imports", "connecting type hierarchy", + "completing type bindings", "processing declare parents", "checking and setting imports", "connecting type hierarchy 1", "building fields and methods", "collecting itds and declares", "processing declare annotations", "weaving intertype declarations", "resolving pointcut declarations", "adding declare warning and errors", "validating @AspectJ annotations", "creating accessors for inlining", "adding @AspectJ annotations", "fixing super calls in ITDs in interface context", "fixing super calls in ITDs", - "optimizing thisJoinPoint calls", + "optimizing thisJoinPoint calls", "connecting type hierarchy 2", // BACK END diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index a97f3fa8a..ff30bfc29 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -146,14 +146,14 @@ public void completeTypeBindings() { stepCompleted = CHECK_AND_SET_IMPORTS; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY, + ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY1, units[i].compilationResult.fileName); units[i].scope.connectTypeHierarchy1(); CompilationAndWeavingContext.leavingPhase(tok); } stepCompleted = CONNECT_TYPE_HIERARCHY1; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY, + ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY2, units[i].compilationResult.fileName); units[i].scope.connectTypeHierarchy2(); CompilationAndWeavingContext.leavingPhase(tok); From 3e81ed505a8c74c073197ef9c8368b7e9f6dc02f Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 1 Oct 2023 12:56:22 +0700 Subject: [PATCH 07/29] AjLookupEnvironment: readability refactoring While trying to understand the code a bit better in order to fix failing builds, I applied some cosmetic refactoring and reformatting. This commit does not change any functionality. Whether the static import of CompilationAndWeavingContext.* is a good thing or not is debatable, but I like the code to be less chatty than it was before, assuming that every developer uses an IDE helping to find out where static methods and constants come from. Signed-off-by: Alexander Kriegisch --- .../compiler/lookup/AjLookupEnvironment.java | 1097 ++++++++--------- 1 file changed, 515 insertions(+), 582 deletions(-) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index ff30bfc29..6fc9de7dd 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -20,7 +20,6 @@ import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration; import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessage; -import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.bridge.context.ContextToken; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; @@ -72,14 +71,20 @@ import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareParents; +import static org.aspectj.bridge.context.CompilationAndWeavingContext.*; + /** - * Overrides the default eclipse LookupEnvironment for two purposes. - * - * 1. To provide some additional phases to completeTypeBindings that weave declare parents and inter-type declarations - * at the correct time. - * - * 2. To intercept the loading of new binary types to ensure the they will have declare parents and inter-type declarations woven - * when appropriate. + * Overrides the default Eclipse {@link LookupEnvironment} for two purposes: + *
    + *
  1. + * To provide some additional phases to {@code completeTypeBindings}, that weave declare parents and inter-type + * declarations at the correct time. + *
  2. + *
  3. + * To intercept loading of new binary types, to ensure they will have declare parents and inter-type declarations + * woven when appropriate. + *
  4. + *
* * @author Jim Hugunin */ @@ -90,27 +95,16 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC private final List pendingTypesToWeave = new ArrayList<>(); // Q: What are dangerousInterfaces? - // A: An interface is considered dangerous if an ITD has been made upon it - // and that ITD - // requires the top most implementors of the interface to be woven *and yet* - // the aspect - // responsible for the ITD is not in the 'world'. + // A: An interface is considered dangerous if an ITD has been made upon it and that ITD requires the top most + // implementors of the interface to be woven *and yet* the aspect responsible for the ITD is not in the 'world'. + // // Q: Err, how can that happen? - // A: When a type is on the inpath, it is 'processed' when completing type - // bindings. At this - // point we look at any type mungers it was affected by previously (stored - // in the weaver - // state info attribute). Effectively we are working with a type munger and - // yet may not have its - // originating aspect in the world. This is a problem if, for example, the - // aspect supplied - // a 'body' for a method targetting an interface - since the top most - // implementors should - // be woven by the munger from the aspect. When this happens we store the - // interface name here - // in the map - if we later process a type that is the topMostImplementor of - // a dangerous - // interface then we put out an error message. + // A: When a type is on the inpath, it is 'processed' when completing type bindings. At this point, we look at any + // type mungers it was affected by previously (stored in the weaver state info attribute). Effectively, we are + // working with a type munger and yet may not have its originating aspect in the world. This is a problem if e.g., + // the aspect supplied a 'body' for a method targetting an interface - since the top most implementors should be + // woven by the munger from the aspect. When this happens we store the interface name here in the map - if we later + // process a type that is the topMostImplementor of a dangerous interface, then we put out an error message. /** * interfaces targetted by ITDs that have to be implemented by accessing the topMostImplementor of the interface, yet the aspect @@ -119,7 +113,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC private final Map dangerousInterfaces = new HashMap<>(); public AjLookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions options, ProblemReporter problemReporter, - INameEnvironment nameEnvironment) { + INameEnvironment nameEnvironment) { super(typeRequestor, options, problemReporter, nameEnvironment); } @@ -131,45 +125,38 @@ public AjLookupEnvironment(LookupEnvironment env, ModuleBinding moduleBinding) { @Override public void completeTypeBindings() { AsmManager.setCompletingTypeBindings(true); - ContextToken completeTypeBindingsToken = CompilationAndWeavingContext.enteringPhase( - CompilationAndWeavingContext.COMPLETING_TYPE_BINDINGS, ""); + ContextToken completeTypeBindingsToken = enteringPhase(COMPLETING_TYPE_BINDINGS, ""); // builtInterTypesAndPerClauses = false; // pendingTypesToWeave = new ArrayList(); stepCompleted = BUILD_TYPE_HIERARCHY; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CHECK_AND_SET_IMPORTS, - units[i].compilationResult.fileName); + ContextToken tok = enteringPhase(CHECK_AND_SET_IMPORTS, units[i].compilationResult.fileName); units[i].scope.checkAndSetImports(); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } stepCompleted = CHECK_AND_SET_IMPORTS; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY1, - units[i].compilationResult.fileName); + ContextToken tok = enteringPhase(CONNECTING_TYPE_HIERARCHY1, units[i].compilationResult.fileName); units[i].scope.connectTypeHierarchy1(); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } stepCompleted = CONNECT_TYPE_HIERARCHY1; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY2, - units[i].compilationResult.fileName); + ContextToken tok = enteringPhase(CONNECTING_TYPE_HIERARCHY2, units[i].compilationResult.fileName); units[i].scope.connectTypeHierarchy2(); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } stepCompleted = CONNECT_TYPE_HIERARCHY2; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS, - units[i].compilationResult.fileName); - // units[i].scope.checkParameterizedTypes(); do this check a little - // later, after ITDs applied to stbs + ContextToken tok = enteringPhase(BUILDING_FIELDS_AND_METHODS, units[i].compilationResult.fileName); + // units[i].scope.checkParameterizedTypes(); do this check a little later, after ITDs applied to stbs units[i].scope.buildFieldsAndMethods(); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } - // would like to gather up all TypeDeclarations at this point and put - // them in the factory + // would like to gather up all TypeDeclarations at this point and put them in the factory for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { SourceTypeBinding[] b = units[i].scope.topLevelTypes; for (SourceTypeBinding sourceTypeBinding : b) { @@ -182,14 +169,11 @@ public void completeTypeBindings() { } } - // We won't find out about anonymous types until later though, so - // register to be - // told about them when they turn up. + // We won't find out about anonymous types until later though, so register to be told about them when they turn up AnonymousClassPublisher.aspectOf().setAnonymousClassCreationListener(this); - // need to build inter-type declarations for all AspectDeclarations at - // this point - // this MUST be done in order from super-types to subtypes + // Need to build inter-type declarations for all AspectDeclarations at this point. This MUST be done in order from + // super-types to subtypes. List typesToProcess = new ArrayList<>(); List aspectsToProcess = new ArrayList<>(); for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { @@ -210,7 +194,7 @@ public void completeTypeBindings() { processInterTypeMemberTypes(aspectToProcess.scope); } - while (typesToProcess.size() > 0) { + while (!typesToProcess.isEmpty()) { // removes types from the list as they are processed... collectAllITDsAndDeclares(typesToProcess.get(0), typesToProcess); } @@ -225,30 +209,20 @@ public void completeTypeBindings() { doPendingWeaves(); - // We now have some list of types to process, and we are about to apply - // the type mungers. - // There can be situations where the order of types passed to the - // compiler causes the - // output from the compiler to vary - THIS IS BAD. For example, if we - // have class A - // and class B extends A. Also, an aspect that 'declare parents: A+ - // implements Serializable' - // then depending on whether we see A first, we may or may not make B - // serializable. - - // The fix is to process them in the right order, ensuring that for a - // type we process its - // supertypes and superinterfaces first. This algorithm may have - // problems with: - // - partial hierarchies (e.g. suppose types A,B,C are in a hierarchy - // and A and C are to be woven but not B) - // - weaving that brings new types in for processing (see - // pendingTypesToWeave.add() calls) after we thought - // we had the full list. + // We now have some list of types to process, and we are about to apply the type mungers. There can be situations + // where the order of types passed to the compiler causes the output from the compiler to vary - THIS IS BAD. + // For example, if we have class A and class B extends A. Also, an aspect that 'declare parents: A+ implements + // Serializable', then depending on whether we see A first, we may or may not make B serializable. + // + // The fix is to process them in the right order, ensuring that for a type we process its supertypes and + // superinterfaces first. This algorithm may have problems with: + // - partial hierarchies (e.g. suppose types A,B,C are in a hierarchy and A and C are to be woven but not B) + // - weaving that brings new types in for processing (see pendingTypesToWeave.add() calls) after we thought + // we had the full list. // // but these aren't common cases (he bravely said...) - boolean typeProcessingOrderIsImportant = declareParents.size() > 0 || declareAnnotationOnTypes.size() > 0; // DECAT + boolean typeProcessingOrderIsImportant = !declareParents.isEmpty() || !declareAnnotationOnTypes.isEmpty(); // DECAT if (typeProcessingOrderIsImportant) { typesToProcess = new ArrayList<>(); for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { @@ -257,16 +231,23 @@ public void completeTypeBindings() { Collections.addAll(typesToProcess, stbs); } - List stb2 = new ArrayList<>(typesToProcess); + List typesToProcessCopy = new ArrayList<>(typesToProcess); - while (typesToProcess.size() > 0) { + while (!typesToProcess.isEmpty()) { // A side effect of weaveIntertypes() is that the processed type is removed from the collection - weaveIntertypes(typesToProcess, typesToProcess.get(0), typeMungers, declareParents, declareAnnotationOnTypes, 1); + weaveIntertypes( + typesToProcess, typesToProcess.get(0), typeMungers, declareParents, declareAnnotationOnTypes, + 1 // do declare parents + ); } - while (stb2.size() > 0) { + typesToProcess = typesToProcessCopy; + while (!typesToProcess.isEmpty()) { // A side effect of weaveIntertypes() is that the processed type is removed from the collection - weaveIntertypes(stb2, stb2.get(0), typeMungers, declareParents, declareAnnotationOnTypes, 2); + weaveIntertypes( + typesToProcess, typesToProcess.get(0), typeMungers, declareParents, declareAnnotationOnTypes, + 2 // do ITDs + ); } } else { @@ -283,20 +264,18 @@ public void completeTypeBindings() { for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { SourceTypeBinding[] b = units[i].scope.topLevelTypes; for (SourceTypeBinding sourceTypeBinding : b) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase( - CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS, sourceTypeBinding.sourceName); + ContextToken tok = enteringPhase(RESOLVING_POINTCUT_DECLARATIONS, sourceTypeBinding.sourceName); resolvePointcutDeclarations(sourceTypeBinding.scope); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } } for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { SourceTypeBinding[] b = units[i].scope.topLevelTypes; for (SourceTypeBinding sourceTypeBinding : b) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase( - CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS, sourceTypeBinding.sourceName); + ContextToken tok = enteringPhase(ADDING_DECLARE_WARNINGS_AND_ERRORS, sourceTypeBinding.sourceName); addAdviceLikeDeclares(sourceTypeBinding.scope); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } } @@ -308,59 +287,53 @@ public void completeTypeBindings() { lastCompletedUnitIndex = lastUnitIndex; AsmManager.setCompletingTypeBindings(false); factory.getWorld().getCrosscuttingMembersSet().verify(); - CompilationAndWeavingContext.leavingPhase(completeTypeBindingsToken); + leavingPhase(completeTypeBindingsToken); if (isProcessingAnnotations) { throw new SourceTypeCollisionException(); // TODO(yushkovskiy): temporary solution; forcing to recompile units to insert mungers into types } } - // /** - // * For any given sourcetypebinding, this method checks that if it is a - // parameterized aspect that - // * the type parameters specified for any supertypes meet the bounds for - // the generic type - // * variables. - // */ - // private void verifyAnyTypeParametersMeetBounds(SourceTypeBinding - // sourceType) { - // ResolvedType onType = factory.fromEclipse(sourceType); - // if (onType.isAspect()) { - // ResolvedType superType = factory.fromEclipse(sourceType.superclass); - // // Don't need to check if it was used in its RAW form or isnt generic - // if (superType.isGenericType() || superType.isParameterizedType()) { - // TypeVariable[] typeVariables = superType.getTypeVariables(); - // UnresolvedType[] typeParams = superType.getTypeParameters(); - // if (typeVariables!=null && typeParams!=null) { - // for (int i = 0; i < typeVariables.length; i++) { - // boolean ok = - // typeVariables[i].canBeBoundTo(typeParams[i].resolve(factory.getWorld())); - // if (!ok) { // the supplied parameter violates the bounds - // // Type {0} does not meet the specification for type parameter {1} ({2}) - // in generic type {3} - // String msg = - // WeaverMessages.format( - // WeaverMessages.VIOLATES_TYPE_VARIABLE_BOUNDS, - // typeParams[i], - // new Integer(i+1), - // typeVariables[i].getDisplayName(), - // superType.getGenericType().getName()); - // factory.getWorld().getMessageHandler().handleMessage(MessageUtil.error(msg - // ,onType.getSourceLocation())); - // } - // } - // } - // } - // } - // } - + /** + * For any given sourcetypebinding, this method checks that if it is a parameterized aspect, the type parameters + * specified for any supertypes meet the bounds for the generic type variables. + */ +/* + private void verifyAnyTypeParametersMeetBounds(SourceTypeBinding sourceType) { + ResolvedType onType = factory.fromEclipse(sourceType); + if (onType.isAspect()) { + ResolvedType superType = factory.fromEclipse(sourceType.superclass); + // Don't need to check if it was used in its RAW form or isn't generic + if (superType.isGenericType() || superType.isParameterizedType()) { + TypeVariable[] typeVariables = superType.getTypeVariables(); + UnresolvedType[] typeParams = superType.getTypeParameters(); + if (typeVariables != null && typeParams != null) { + for (int i = 0; i < typeVariables.length; i++) { + boolean ok = typeVariables[i].canBeBoundTo(typeParams[i].resolve(factory.getWorld())); + if (!ok) { // the supplied parameter violates the bounds + // Type {0} does not meet the specification for type parameter {1} ({2}) in generic type {3} + String msg = WeaverMessages.format( + WeaverMessages.VIOLATES_TYPE_VARIABLE_BOUNDS, + typeParams[i], + new Integer(i + 1), + typeVariables[i].getDisplayName(), + superType.getGenericType().getName() + ); + factory.getWorld().getMessageHandler().handleMessage(MessageUtil.error(msg, onType.getSourceLocation())); + } + } + } + } + } + } +*/ public void doSupertypesFirst(ReferenceBinding rb, Collection yetToProcess) { if (rb instanceof SourceTypeBinding) { if (yetToProcess.contains(rb)) { collectAllITDsAndDeclares((SourceTypeBinding) rb, yetToProcess); } } else if (rb instanceof ParameterizedTypeBinding) { - // If its a PTB we need to pull the SourceTypeBinding out of it. + // If it is a PTB, we need to pull the SourceTypeBinding out of it. ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) rb; if (ptb.type instanceof SourceTypeBinding && yetToProcess.contains(ptb.type)) { collectAllITDsAndDeclares((SourceTypeBinding) ptb.type, yetToProcess); @@ -376,8 +349,7 @@ public void doSupertypesFirst(ReferenceBinding rb, Collection yetToProcess) { // Look at the supertype first - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.COLLECTING_ITDS_AND_DECLARES, - sourceType.sourceName); + ContextToken tok = enteringPhase(COLLECTING_ITDS_AND_DECLARES, sourceType.sourceName); yetToProcess.remove(sourceType); // look out our direct supertype @@ -394,7 +366,7 @@ private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection< buildInterTypeAndPerClause(sourceType.scope); addCrosscuttingStructures(sourceType.scope); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } /** @@ -406,16 +378,21 @@ private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection< * * @param mode 0=do everything, 1=do declare parents, 2=do ITDs */ - private void weaveIntertypes(List typesToProcess, SourceTypeBinding typeToWeave, - List typeMungers, List declareParents, - List declareAnnotationOnTypes, int mode) { + private void weaveIntertypes( + List typesToProcess, SourceTypeBinding typeToWeave, + List typeMungers, List declareParents, + List declareAnnotationOnTypes, int mode + ) { // Look at the supertype first ReferenceBinding superType = typeToWeave.superclass(); if (typesToProcess.contains(superType) && superType instanceof SourceTypeBinding) { // System.err.println("Recursing to supertype "+new // String(superType.getFileName())); - weaveIntertypes(typesToProcess, (SourceTypeBinding) superType, typeMungers, declareParents, declareAnnotationOnTypes, - mode); + weaveIntertypes( + typesToProcess, (SourceTypeBinding) superType, + typeMungers, declareParents, declareAnnotationOnTypes, + mode + ); } // Then look at the superinterface list ReferenceBinding[] interfaceTypes = typeToWeave.superInterfaces(); @@ -423,22 +400,36 @@ private void weaveIntertypes(List typesToProcess, SourceTypeB if (typesToProcess.contains(binding) && binding instanceof SourceTypeBinding) { // System.err.println("Recursing to superinterface "+new // String(binding.getFileName())); - weaveIntertypes(typesToProcess, (SourceTypeBinding) binding, typeMungers, declareParents, declareAnnotationOnTypes, - mode); - } else if (binding instanceof ParameterizedTypeBinding && (((ParameterizedTypeBinding) binding).type instanceof SourceTypeBinding) && typesToProcess.contains(((ParameterizedTypeBinding) binding).type)) { - weaveIntertypes(typesToProcess, (SourceTypeBinding) ((ParameterizedTypeBinding) binding).type, typeMungers, declareParents, declareAnnotationOnTypes, mode); + weaveIntertypes( + typesToProcess, (SourceTypeBinding) binding, + typeMungers, declareParents, declareAnnotationOnTypes, + mode + ); + } else if ( + binding instanceof ParameterizedTypeBinding && + (((ParameterizedTypeBinding) binding).type instanceof SourceTypeBinding) && + typesToProcess.contains(((ParameterizedTypeBinding) binding).type) + ) { + weaveIntertypes( + typesToProcess, (SourceTypeBinding) ((ParameterizedTypeBinding) binding).type, + typeMungers, declareParents, declareAnnotationOnTypes, + mode + ); } } - weaveInterTypeDeclarations(typeToWeave, typeMungers, declareParents, declareAnnotationOnTypes, false, mode); + weaveInterTypeDeclarations( + typeToWeave, typeMungers, + declareParents, declareAnnotationOnTypes, false, + mode + ); typesToProcess.remove(typeToWeave); } private void doPendingWeaves() { - for (SourceTypeBinding t: pendingTypesToWeave) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase( - CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS, t.sourceName); + for (SourceTypeBinding t : pendingTypesToWeave) { + ContextToken tok = enteringPhase(WEAVING_INTERTYPE_DECLARATIONS, t.sourceName); weaveInterTypeDeclarations(t); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } pendingTypesToWeave.clear(); } @@ -550,8 +541,8 @@ private void buildInterTypeAndPerClause(ClassScope s) { if (sourceType.superclass != null) { ResolvedType parent = factory.fromEclipse(sourceType.superclass); if (parent.isAspect() && !isAspect(dec)) { - factory.showMessage(IMessage.ERROR, "class \'" + new String(sourceType.sourceName) + "\' can not extend aspect \'" - + parent.getName() + "\'", factory.fromEclipse(sourceType).getSourceLocation(), null); + factory.showMessage(IMessage.ERROR, "class '" + new String(sourceType.sourceName) + "' can not extend aspect '" + + parent.getName() + "'", factory.fromEclipse(sourceType).getSourceLocation(), null); } } @@ -595,10 +586,7 @@ private boolean isAspect(TypeDeclaration decl) { if (!CharOperation.equals("annotation".toCharArray(), qtr.tokens[3])) { return false; } - if (!CharOperation.equals("Aspect".toCharArray(), qtr.tokens[4])) { - return false; - } - return true; + return CharOperation.equals("Aspect".toCharArray(), qtr.tokens[4]); } } } @@ -606,7 +594,7 @@ private boolean isAspect(TypeDeclaration decl) { } private void weaveInterTypeDeclarations(CompilationUnitScope unit, List typeMungers, - List declareParents, List declareAnnotationOnTypes) { + List declareParents, List declareAnnotationOnTypes) { for (int i = 0, length = unit.topLevelTypes.length; i < length; i++) { weaveInterTypeDeclarations(unit.topLevelTypes[i], typeMungers, declareParents, declareAnnotationOnTypes, false, 0); } @@ -617,53 +605,57 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType) { if (!pendingTypesToWeave.contains(sourceType)) { pendingTypesToWeave.add(sourceType); - // inner type ITD support - may need this for some incremental cases... - // List ctms = factory.getWorld().getCrosscuttingMembersSet().getTypeMungersOfKind( - // ResolvedTypeMunger.InnerClass); - // // List innerTypeMungers = new ArrayList(); - // // for (ConcreteTypeMunger ctm : ctms) { - // // if (ctm.getMunger() != null && ctm.getMunger().getKind() == ResolvedTypeMunger.InnerClass) { - // // innerTypeMungers.add(ctm); - // // } - // // } - // // that includes the innertype one... - // // doPendingWeaves at this level is about applying inner class - // BinaryTypeBinding t = (BinaryTypeBinding) sourceType; - // for (ConcreteTypeMunger ctm : innerTypeMungers) { - // NewMemberClassTypeMunger nmctm = (NewMemberClassTypeMunger) ctm.getMunger(); - // ReferenceBinding[] rbs = t.memberTypes; - // UnresolvedType ut = factory.fromBinding(t); - // if (ut.equals(nmctm.getTargetType())) { - // // got a match here - // SourceTypeBinding aspectTypeBinding = (SourceTypeBinding) factory.makeTypeBinding(ctm.getAspectType()); - // - // char[] mungerMemberTypeName = ("$" + nmctm.getMemberTypeName()).toCharArray(); - // ReferenceBinding innerTypeBinding = null; - // for (ReferenceBinding innerType : aspectTypeBinding.memberTypes) { - // char[] compounded = CharOperation.concatWith(innerType.compoundName, '.'); - // if (org.aspectj.org.eclipse.jdt.core.compiler.CharOperation.endsWith(compounded, mungerMemberTypeName)) { - // innerTypeBinding = innerType; - // break; - // } - // } - // // may be unresolved if the aspect type binding was a BinaryTypeBinding - // if (innerTypeBinding instanceof UnresolvedReferenceBinding) { - // innerTypeBinding = BinaryTypeBinding - // .resolveType(innerTypeBinding, factory.getLookupEnvironment(), true); - // } - // t.memberTypes(); // cause initialization - // t.memberTypes = new ReferenceBinding[] { innerTypeBinding }; - // - // int stop = 1; - // // The inner type from the aspect should be put into the membertypebindings for this - // - // } - // } +/* + // Inner type ITD support - may need this for some incremental cases... + List ctms = factory.getWorld() + .getCrosscuttingMembersSet() + .getTypeMungersOfKind(ResolvedTypeMunger.InnerClass); + + List innerTypeMungers = new ArrayList(); + for (ConcreteTypeMunger ctm : ctms) { + if (ctm.getMunger() != null && ctm.getMunger().getKind() == ResolvedTypeMunger.InnerClass) { + innerTypeMungers.add(ctm); + } + } + + // ... that includes the innertype one... + // doPendingWeaves at this level is about applying inner class + BinaryTypeBinding t = (BinaryTypeBinding) sourceType; + for (ConcreteTypeMunger ctm : innerTypeMungers) { + NewMemberClassTypeMunger nmctm = (NewMemberClassTypeMunger) ctm.getMunger(); + ReferenceBinding[] rbs = t.memberTypes; + UnresolvedType ut = factory.fromBinding(t); + if (ut.equals(nmctm.getTargetType())) { + // got a match here + SourceTypeBinding aspectTypeBinding = (SourceTypeBinding) factory.makeTypeBinding(ctm.getAspectType()); + + char[] mungerMemberTypeName = ("$" + nmctm.getMemberTypeName()).toCharArray(); + ReferenceBinding innerTypeBinding = null; + for (ReferenceBinding innerType : aspectTypeBinding.memberTypes) { + char[] compounded = CharOperation.concatWith(innerType.compoundName, '.'); + if (org.aspectj.org.eclipse.jdt.core.compiler.CharOperation.endsWith(compounded, mungerMemberTypeName)) { + innerTypeBinding = innerType; + break; + } + } + // may be unresolved if the aspect type binding was a BinaryTypeBinding + if (innerTypeBinding instanceof UnresolvedReferenceBinding) { + innerTypeBinding = BinaryTypeBinding + .resolveType(innerTypeBinding, factory.getLookupEnvironment(), true); + } + t.memberTypes(); // cause initialization + t.memberTypes = new ReferenceBinding[]{innerTypeBinding}; + + int stop = 1; + // The inner type from the aspect should be put into the membertypebindings for this + } + } +*/ } } else { weaveInterTypeDeclarations(sourceType, factory.getTypeMungers(), factory.getDeclareParents(), - factory.getDeclareAnnotationOnTypes(), true, 0); + factory.getDeclareAnnotationOnTypes(), true, 0); } } @@ -671,10 +663,9 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType) { * @param mode 0=do everything, 1=do declare parents, 2=do ITDs */ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List typeMungers, - List declareParents, List declareAnnotationOnTypes, boolean skipInners, int mode) { + List declareParents, List declareAnnotationOnTypes, boolean skipInners, int mode) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS, - sourceType.sourceName); + ContextToken tok = enteringPhase(WEAVING_INTERTYPE_DECLARATIONS, sourceType.sourceName); ResolvedType onType = factory.fromEclipse(sourceType); @@ -686,26 +677,18 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List entry : dangerousInterfaces.entrySet()) { ResolvedType interfaceType = entry.getKey(); if (onType.isTopmostImplementor(interfaceType)) { @@ -718,25 +701,19 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List decpToRepeat = new ArrayList<>(); List decaToRepeat = new ArrayList<>(); boolean anyNewParents = false; boolean anyNewAnnotations = false; - // first pass - // try and apply all decps - if they match, then great. If they don't - // then - // check if they are starred-annotation patterns. If they are not - // starred - // annotation patterns then they might match later...remember that... + // First pass:Try and apply all decps. If they match, then great. If they don't, then check if they are + // starred-annotation patterns. If they are not starred annotation patterns, then they might match later... + // Remember that... for (DeclareParents decp : declareParents) { if (!decp.isMixin()) { boolean didSomething = doDeclareParents(decp, sourceType); @@ -765,7 +742,7 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List forRemoval = new ArrayList<>(); - // now lets loop over and over until we have done all we can + // Now let's loop over and over, until we have done all we can while ((anyNewAnnotations || anyNewParents) && (!decpToRepeat.isEmpty() || !decaToRepeat.isEmpty())) { anyNewParents = anyNewAnnotations = false; forRemoval.clear(); @@ -831,23 +808,18 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List * sourceType and onType are the 'same type' - the former is the 'Eclipse' version and the latter is the 'Weaver' version. */ private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceType, ResolvedType onType) { @@ -876,7 +848,7 @@ private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceT if (onType.isInterface() && munger.getMunger().needsAccessToTopmostImplementor()) { if (!onType.getWorld().getCrosscuttingMembersSet().containsAspect(munger.getAspectType())) { dangerousInterfaces - .put(onType, "implementors of " + onType + " must be woven by " + munger.getAspectType()); + .put(onType, "implementors of " + onType + " must be woven by " + munger.getAspectType()); } } } @@ -885,8 +857,7 @@ private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceT } private boolean doDeclareParents(DeclareParents declareParents, SourceTypeBinding sourceType) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS, - sourceType.sourceName); + ContextToken tok = enteringPhase(PROCESSING_DECLARE_PARENTS, sourceType.sourceName); ResolvedType resolvedSourceType = factory.fromEclipse(sourceType); List newParents = declareParents.findMatchingNewParents(resolvedSourceType, false); if (!newParents.isEmpty()) { @@ -894,28 +865,28 @@ private boolean doDeclareParents(DeclareParents declareParents, SourceTypeBindin if (dangerousInterfaces.containsKey(parent)) { ResolvedType onType = factory.fromEclipse(sourceType); factory.showMessage(IMessage.ERROR, onType + ": " + dangerousInterfaces.get(parent), - onType.getSourceLocation(), null); + onType.getSourceLocation(), null); } if (Modifier.isFinal(parent.getModifiers())) { factory.showMessage(IMessage.ERROR, "cannot extend final class " + parent.getClassName(), - declareParents.getSourceLocation(), null); + declareParents.getSourceLocation(), null); } else { // do not actually do it if the type isn't exposed - this // will correctly reported as a problem elsewhere if (!resolvedSourceType.isExposedToWeaver()) { return false; } - // AsmRelationshipProvider.getDefault(). - // addDeclareParentsRelationship - // (declareParents.getSourceLocation(), - // factory.fromEclipse(sourceType), newParents); + // AsmRelationshipProvider.getDefault() + // .addDeclareParentsRelationship( + // declareParents.getSourceLocation(), factory.fromEclipse(sourceType), newParents + // ); addParent(sourceType, parent); } } - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return true; } - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } @@ -950,7 +921,7 @@ private String stringifyTargets(long bits) { } StringBuilder sb = new StringBuilder(); sb.append("{"); - for (Iterator iter = s.iterator(); iter.hasNext();) { + for (Iterator iter = s.iterator(); iter.hasNext(); ) { String element = iter.next(); sb.append(element); if (iter.hasNext()) { @@ -970,8 +941,7 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s return false; } - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_ANNOTATIONS, - sourceType.sourceName); + ContextToken tok = enteringPhase(PROCESSING_DECLARE_ANNOTATIONS, sourceType.sourceName); // Get the annotation specified in the declare UnresolvedType aspectType = decA.getAspect(); @@ -984,21 +954,14 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s TypeBinding tb = factory.makeTypeBinding(aspectType); // Hideousness follows: - - // There are multiple situations to consider here and they relate to the - // combinations of - // where the annotation is coming from and where the annotation is going - // to be put: // - // 1. Straight full build, all from source - the annotation is from a - // dec@type and - // is being put on some type. Both types are real SourceTypeBindings. - // WORKS - // 2. Incremental build, changing the affected type - the annotation is - // from a - // dec@type in a BinaryTypeBinding (so has to be accessed via bcel) and - // the - // affected type is a real SourceTypeBinding. Mostly works (pr128665) + // There are multiple situations to consider here, and they relate to the combinations of where the annotation is + // coming from and where the annotation is going to be put: + // + // 1. Straight full build, all from source - the annotation is from a dec@type and is being put on some type. Both + // types are real SourceTypeBindings. WORKS + // 2. Incremental build, changing the affected type - the annotation is from a dec@type in a BinaryTypeBinding (so + // has to be accessed via bcel) and the affected type is a real SourceTypeBinding. Mostly works (pr128665) // 3. ? SourceTypeBinding stb = (SourceTypeBinding) tb; @@ -1006,16 +969,14 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s long abits = 0; AbstractMethodDeclaration methodDecl = null; - // Might have to retrieve the annotation through BCEL and construct an - // eclipse one for it. + // Might have to retrieve the annotation through BCEL and construct an Eclipse one for it if (stb instanceof BinaryTypeBinding) { toAdd = retrieveAnnotationFromBinaryTypeBinding(decA, stb); if (toAdd != null && toAdd.length > 0 && toAdd[0].resolvedType != null) { abits = toAdd[0].resolvedType.getAnnotationTagBits(); } } else if (stb != null) { - // much nicer, its a real SourceTypeBinding so we can stay in - // eclipse land + // Much nicer, it's a real SourceTypeBinding so we can stay in Eclipse land // if (decA.getAnnotationMethod() != null) { char[] declareSelector = decA.getAnnotationMethod().toCharArray(); @@ -1051,13 +1012,12 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s // This happens if there is another error in the code - that should be reported separately if (toAdd == null || toAdd[0] == null || toAdd[0].type == null) { - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } if (sourceType instanceof BinaryTypeBinding) { - // In this case we can't access the source type binding to add a new - // annotation, so let's put something - // on the weaver type temporarily + // In this case we can't access the source type binding to add a new annotation, so let's put something on the + // weaver type temporarily ResolvedType theTargetType = factory.fromEclipse(sourceType); TypeBinding theAnnotationType = toAdd[0].resolvedType; // The annotation type may be null if it could not be resolved (eg. the relevant import has not been added yet) @@ -1069,7 +1029,7 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s UnresolvedType bcelAnnotationType = UnresolvedType.forSignature(sig); String name = bcelAnnotationType.getName(); if (theTargetType.hasAnnotation(bcelAnnotationType)) { - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } @@ -1081,53 +1041,53 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s // error will have been already reported giveupnow = true; } else if ((sourceType.isAnnotationType() && (abits & TagBits.AnnotationForAnnotationType) == 0) - || (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType) == 0)) { + || (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType) == 0)) { if (reportProblems) { if (decA.isExactPattern()) { factory.showMessage(IMessage.ERROR, WeaverMessages.format( - WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type, - stringifyTargets(abits)), decA.getSourceLocation(), null); + WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type, + stringifyTargets(abits)), decA.getSourceLocation(), null); } - // dont put out the lint - the weaving process will do - // that - // else { - // if (factory.getWorld().getLint(). - // invalidTargetForAnnotation.isEnabled()) { - // factory.getWorld().getLint().invalidTargetForAnnotation - // .signal(new - // String[]{rtx.getName(),toAdd[0].type.toString(), - // stringifyTargets - // (abits)},decA.getSourceLocation(),null); - // } - // } + // Don't put out the lint - the weaving process will do that + /* + else { + if (factory.getWorld().getLint(). + invalidTargetForAnnotation.isEnabled()) { + factory.getWorld().getLint().invalidTargetForAnnotation + .signal( + new String[] {rtx.getName(), toAdd[0].type.toString(), stringifyTargets(abits)}, + decA.getSourceLocation(), + null + ); + } + } + */ } giveupnow = true; } } if (giveupnow) { - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } theTargetType.addAnnotation(new BcelAnnotation(new FakeAnnotation(name, sig, - (abits & TagBits.AnnotationRuntimeRetention) != 0), factory.getWorld())); - CompilationAndWeavingContext.leavingPhase(tok); + (abits & TagBits.AnnotationRuntimeRetention) != 0), factory.getWorld())); + leavingPhase(tok); return true; } - Annotation currentAnnotations[] = sourceType.scope.referenceContext.annotations; + Annotation[] currentAnnotations = sourceType.scope.referenceContext.annotations; if (currentAnnotations != null) { for (Annotation annotation : currentAnnotations) { String a = CharOperation.toString(annotation.type.getTypeName()); String b = CharOperation.toString(toAdd[0].type.getTypeName()); - // FIXME asc we have a lint for attempting to add an annotation - // twice to a method, - // we could put it out here *if* we can resolve the problem of - // errors coming out - // multiple times if we have cause to loop through here + // FIXME asc + // We have a lint for attempting to add an annotation twice to a method, we could put it out here *if* we can + // resolve the problem of errors coming out multiple times if we have cause to loop through here. if (a.equals(b)) { - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } } @@ -1135,42 +1095,43 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s if (((abits & TagBits.AnnotationTargetMASK) != 0)) { if ((abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) == 0) { - // this means it specifies something other than annotation or - // normal type - error will have been already reported, - // just resolution process above - CompilationAndWeavingContext.leavingPhase(tok); + // This means, it specifies something other than annotation or normal type - error will have been already + // reported, just resolution process above. + leavingPhase(tok); return false; } if ((sourceType.isAnnotationType() && (abits & TagBits.AnnotationForAnnotationType) == 0) - || (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType) == 0)) { + || (!sourceType.isAnnotationType() && (abits & TagBits.AnnotationForType) == 0)) { if (reportProblems) { if (decA.isExactPattern()) { factory.showMessage(IMessage.ERROR, WeaverMessages.format( - WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type, - stringifyTargets(abits)), decA.getSourceLocation(), null); + WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type, + stringifyTargets(abits)), decA.getSourceLocation(), null); } - // dont put out the lint - the weaving process will do that - // else { - // if - // (factory.getWorld().getLint().invalidTargetForAnnotation - // .isEnabled()) { - // factory.getWorld().getLint().invalidTargetForAnnotation. - // signal(new - // String[]{rtx.getName(),toAdd[0].type.toString(), - // stringifyTargets(abits)},decA.getSourceLocation(),null); - // } - // } + // Don't put out the lint - the weaving process will do that + /* + else { + if + (factory.getWorld().getLint().invalidTargetForAnnotation.isEnabled()) { + factory.getWorld().getLint().invalidTargetForAnnotation + .signal( + new String[] {rtx.getName(), toAdd[0].type.toString(), stringifyTargets(abits)}, + decA.getSourceLocation(), + null + ); + } + } + */ } - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); return false; } } // Build a new array of annotations - // remember the current set (rememberAnnotations only does something the - // first time it is called for a type) + // Remember the current set (rememberAnnotations only does something the first time it is called for a type) sourceType.scope.referenceContext.rememberAnnotations(); // AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship( @@ -1182,13 +1143,13 @@ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding s System.arraycopy(abefore, 0, newset, toAdd.length, abefore.length); } sourceType.scope.referenceContext.annotations = newset; - if ((sourceType.tagBits & TagBits.AnnotationResolved)!=0) { + if ((sourceType.tagBits & TagBits.AnnotationResolved) != 0) { sourceType.tagBits = sourceType.tagBits - TagBits.AnnotationResolved; } - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); if (factory.pushinCollector != null) { factory.pushinCollector.tagAsMunged(sourceType, new CommonPrinter((methodDecl == null ? null : methodDecl.scope)) - .printAnnotation(toAdd[0]).toString()); + .printAnnotation(toAdd[0]).toString()); } return true; } @@ -1209,13 +1170,11 @@ private Annotation[] retrieveAnnotationFromBinaryTypeBinding(DeclareAnnotation d if (axs != null) { // another error has occurred, dont crash here because of it Annotation[] toAdd = new Annotation[1]; toAdd[0] = createAnnotationFromBcelAnnotation(axs[0], decaMethod.getSourceLocation().getOffset(), factory); - // BUG BUG BUG - We dont test these abits are correct, in fact - // we'll be very lucky if they are. - // What does that mean? It means on an incremental compile you - // might get away with an - // annotation that isn't allowed on a type being put on a type. + // BUG BUG BUG - We don't test these abits are correct, in fact we'll be very lucky if they are. + // What does that mean? It means on an incremental compile you might get away with an annotation that isn't + // allowed on a type being put on a type. // if (toAdd[0].resolvedType != null) { - // abits = toAdd[0].resolvedType.getAnnotationTagBits(); + // abits = toAdd[0].resolvedType.getAnnotationTagBits(); // } return toAdd; } @@ -1294,46 +1253,50 @@ private boolean isAnnotationTargettingSomethingOtherThanAnnotationOrNormal(long return (abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType)) == 0; } -// private void reportDeclareParentsMessage(WeaveMessage.WeaveMessageKind wmk, SourceTypeBinding sourceType, ResolvedType parent) { -// if (!factory.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { -// String filename = new String(sourceType.getFileName()); -// -// int takefrom = filename.lastIndexOf('/'); -// if (takefrom == -1) { -// takefrom = filename.lastIndexOf('\\'); -// } -// filename = filename.substring(takefrom + 1); -// -// factory.getWorld() -// .getMessageHandler() -// .handleMessage( -// WeaveMessage.constructWeavingMessage(wmk, -// new String[] { CharOperation.toString(sourceType.compoundName), filename, -// parent.getClassName(), -// getShortname(parent.getSourceLocation().getSourceFile().getPath()) })); -// } -// } - -// private String getShortname(String path) { -// int takefrom = path.lastIndexOf('/'); -// if (takefrom == -1) { -// takefrom = path.lastIndexOf('\\'); -// } -// return path.substring(takefrom + 1); -// } +/* + private void reportDeclareParentsMessage(WeaveMessage.WeaveMessageKind wmk, SourceTypeBinding sourceType, ResolvedType parent) { + if (!factory.getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { + String filename = new String(sourceType.getFileName()); + + int takefrom = filename.lastIndexOf('/'); + if (takefrom == -1) { + takefrom = filename.lastIndexOf('\\'); + } + filename = filename.substring(takefrom + 1); + + factory.getWorld() + .getMessageHandler() + .handleMessage( + WeaveMessage.constructWeavingMessage(wmk, + new String[] { CharOperation.toString(sourceType.compoundName), filename, + parent.getClassName(), + getShortname(parent.getSourceLocation().getSourceFile().getPath()) })); + } + } +*/ + +/* + private String getShortname(String path) { + int takefrom = path.lastIndexOf('/'); + if (takefrom == -1) { + takefrom = path.lastIndexOf('\\'); + } + return path.substring(takefrom + 1); + } +*/ private void addParent(SourceTypeBinding sourceType, ResolvedType parent) { ReferenceBinding parentBinding = (ReferenceBinding) factory.makeTypeBinding(parent); if (parentBinding == null) { return; // The parent is missing, it will be reported elsewhere. } - // Due to e37 switching to MethodVerifier15 for everything, it is important added types are correctly - // raw or not. For example, if Comparable is used in generic form compareTo(T) will be used to check - // methods against in the verifier rather than compareTo(Object) + // Due to e37 switching to MethodVerifier15 for everything, it is important added types are correctly raw or not. + // For example, if Comparable is used in generic form compareTo(T) will be used to check methods against in the + // verifier rather than compareTo(Object) if (!factory.getWorld().isInJava5Mode()) { - parentBinding = (ReferenceBinding)convertToRawType(parentBinding, false /*do not force conversion of enclosing types*/); + parentBinding = (ReferenceBinding) convertToRawType(parentBinding, false /*do not force conversion of enclosing types*/); } else if (sourceType.isGenericType()) { - RawTypeBinding rawTargetType = (RawTypeBinding)convertToRawType(sourceType, false); + RawTypeBinding rawTargetType = (RawTypeBinding) convertToRawType(sourceType, false); if (rawTargetType != null) { // assert: don't need to 'rememberTypeHierarchy' because the class file is constructed based on the generic type if (parentBinding.isClass()) { @@ -1359,13 +1322,10 @@ private void addParent(SourceTypeBinding sourceType, ResolvedType parent) { if (parentBinding.isClass()) { sourceType.superclass = parentBinding; - // this used to be true, but I think I've fixed it now, decp is done - // at weave time! + // This used to be true, but I think I've fixed it now, decp is done at weave time! // TAG: WeavingMessage DECLARE PARENTS: EXTENDS - // Compiler restriction: Can't do EXTENDS at weave time - // So, only see this message if doing a source compilation - // reportDeclareParentsMessage(WeaveMessage. - // WEAVEMESSAGE_DECLAREPARENTSEXTENDS,sourceType,parent); + // Compiler restriction: Can't do EXTENDS at weave time So, only see this message if doing a source compilation + // reportDeclareParentsMessage(WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSEXTENDS,sourceType,parent); } else { ReferenceBinding[] oldI = sourceType.superInterfaces; @@ -1380,20 +1340,16 @@ private void addParent(SourceTypeBinding sourceType, ResolvedType parent) { newI[n] = parentBinding; } sourceType.superInterfaces = newI; - // warnOnAddedInterface(factory.fromEclipse(sourceType),parent); // - // now reported at weave time... + // warnOnAddedInterface(factory.fromEclipse(sourceType),parent); // now reported at weave time... - // this used to be true, but I think I've fixed it now, decp is done - // at weave time! + // This used to be true, but I think I've fixed it now, decp is done at weave time! // TAG: WeavingMessage DECLARE PARENTS: IMPLEMENTS - // This message will come out of BcelTypeMunger.munge if doing a - // binary weave - // reportDeclareParentsMessage(WeaveMessage. - // WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS,sourceType,parent); + // This message will come out of BcelTypeMunger.munge if doing a binary weave + // reportDeclareParentsMessage(WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS,sourceType,parent); } - // also add it to the bcel delegate if there is one + // Also add it to the bcel delegate if there is one if (sourceType instanceof BinaryTypeBinding) { ResolvedType onType = factory.fromEclipse(sourceType); ReferenceType rt = (ReferenceType) onType; @@ -1413,9 +1369,9 @@ public void warnOnAddedInterface(ResolvedType type, ResolvedType parent) { World world = factory.getWorld(); ResolvedType serializable = world.getCoreType(UnresolvedType.SERIALIZABLE); if (serializable.isAssignableFrom(type) && !serializable.isAssignableFrom(parent) - && !LazyClassGen.hasSerialVersionUIDField(type)) { - world.getLint().needsSerialVersionUIDField.signal(new String[] { type.getName().toString(), - "added interface " + parent.getName().toString() }, null, null); + && !LazyClassGen.hasSerialVersionUIDField(type)) { + world.getLint().needsSerialVersionUIDField.signal(new String[]{type.getName(), + "added interface " + parent.getName()}, null, null); } } @@ -1425,7 +1381,7 @@ public void warnOnAddedInterface(ResolvedType type, ResolvedType parent) { @Override public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBinding packageBinding, - boolean needFieldsAndMethods, AccessRestriction accessRestriction) { + boolean needFieldsAndMethods, AccessRestriction accessRestriction) { if (inBinaryTypeCreationAndWeaving) { BinaryTypeBinding ret = super.createBinaryTypeFrom(binaryType, packageBinding, needFieldsAndMethods, accessRestriction); @@ -1445,7 +1401,7 @@ public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBin inBinaryTypeCreationAndWeaving = false; // Start processing the list... - if (pendingTypesToFinish.size() > 0) { + if (!pendingTypesToFinish.isEmpty()) { processingTheQueue = true; while (!pendingTypesToFinish.isEmpty()) { BinaryTypeBinding nextVictim = pendingTypesToFinish.remove(0); @@ -1469,201 +1425,178 @@ public void anonymousTypeBindingCreated(LocalTypeBinding aBinding) { factory.addSourceTypeBinding(aBinding, null); } - @Override - public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction accessRestriction) { - if (this.isProcessingAnnotations && hasAspectDeclarations(unit)) { - throw new SourceTypeCollisionException(); - } - super.buildTypeBindings(unit, accessRestriction); - } - - private static boolean hasAspectDeclarations(CompilationUnitDeclaration unit) { - if (unit.types == null) - return false; - for (int j = 0; j < unit.types.length; j++) { - if (unit.types[j] instanceof AspectDeclaration) { - return true; - } - } - return false; - } - - @Override - public void reset() { - this.factory.cleanup(); - super.reset(); - } - - @Override -public LookupEnvironment wrapInModuleEnvironment(ModuleBinding moduleBinding) { - AjLookupEnvironment newAjLookupEnvironment = new AjLookupEnvironment(this, moduleBinding); - newAjLookupEnvironment.factory = this.factory; - return newAjLookupEnvironment; - } -} + @Override + public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction accessRestriction) { + if (this.isProcessingAnnotations && hasAspectDeclarations(unit)) { + throw new SourceTypeCollisionException(); + } + super.buildTypeBindings(unit, accessRestriction); + } -// commented out, supplied as info on how to manipulate annotations in an -// eclipse world -// -// public void doDeclareAnnotationOnMethods() { -// Do the declare annotation on fields/methods/ctors -// Collection daoms = factory.getDeclareAnnotationOnMethods(); -// if (daoms!=null && daoms.size()>0 && !(sourceType instanceof -// BinaryTypeBinding)) { -// System.err.println("Going through the methods on "+sourceType.debugName()+ -// " looking for DECA matches"); -// // We better take a look through them... -// for (Iterator iter = daoms.iterator(); iter.hasNext();) { -// DeclareAnnotation element = (DeclareAnnotation) iter.next(); -// System.err.println("Looking for anything that might match "+element+" on "+ -// sourceType.debugName()+" "+getType(sourceType. -// compoundName).debugName()+" "+(sourceType instanceof BinaryTypeBinding)); -// -// ReferenceBinding rbb = getType(sourceType.compoundName); -// // fix me if we ever uncomment this code... should iterate the other way -// round, over the methods then over the decas -// sourceType.methods(); -// MethodBinding sourceMbs[] = sourceType.methods; -// for (int i = 0; i < sourceMbs.length; i++) { -// MethodBinding sourceMb = sourceMbs[i]; -// MethodBinding mbbbb = -// ((SourceTypeBinding)rbb).getExactMethod(sourceMb.selector -// ,sourceMb.parameters); -// boolean isCtor = sourceMb.selector[0]=='<'; -// -// if ((element.isDeclareAtConstuctor() ^ !isCtor)) { -// System.err.println("Checking "+sourceMb+" ... declaringclass="+sourceMb. -// declaringClass.debugName()+" rbb="+rbb.debugName()+" "+ -// sourceMb.declaringClass.equals(rbb)); -// -// ResolvedMember rm = null; -// rm = EclipseFactory.makeResolvedMember(mbbbb); -// if (element.matches(rm,factory.getWorld())) { -// System.err.println("MATCH"); -// -// // Determine the set of annotations that are currently on the method -// ReferenceBinding rb = getType(sourceType.compoundName); -// // TypeBinding tb = factory.makeTypeBinding(decA.getAspect()); -// MethodBinding mb = -// ((SourceTypeBinding)rb).getExactMethod(sourceMb.selector,sourceMb -// .parameters); -// //long abits = mbs[0].getAnnotationTagBits(); // ensure resolved -// TypeDeclaration typeDecl = -// ((SourceTypeBinding)sourceMb.declaringClass).scope.referenceContext; -// AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(sourceMb); -// Annotation[] currentlyHas = methodDecl.annotations; // this is what to add -// //abits = toAdd[0].resolvedType.getAnnotationTagBits(); -// -// // Determine the annotations to add to that method -// TypeBinding tb = factory.makeTypeBinding(element.getAspect()); -// MethodBinding[] aspectMbs = -// ((SourceTypeBinding)tb).getMethods(element.getAnnotationMethod -// ().toCharArray()); -// long abits = aspectMbs[0].getAnnotationTagBits(); // ensure resolved -// TypeDeclaration typeDecl2 = -// ((SourceTypeBinding)aspectMbs[0].declaringClass).scope.referenceContext; -// AbstractMethodDeclaration methodDecl2 = -// typeDecl2.declarationOf(aspectMbs[0]); -// Annotation[] toAdd = methodDecl2.annotations; // this is what to add -// // abits = toAdd[0].resolvedType.getAnnotationTagBits(); -// System.err.println("Has: "+currentlyHas+" toAdd: "+toAdd); -// -// // fix me? should check if it already has the annotation -// //Annotation abefore[] = sourceType.scope.referenceContext.annotations; -// Annotation[] newset = new -// Annotation[(currentlyHas==null?0:currentlyHas.length)+1]; -// System.arraycopy(toAdd,0,newset,0,toAdd.length); -// if (currentlyHas!=null) { -// System.arraycopy(currentlyHas,0,newset,1,currentlyHas.length); -// } -// methodDecl.annotations = newset; -// System.err.println("New set on "+CharOperation.charToString(sourceMb.selector) -// +" is "+newset); -// } else -// System.err.println("NO MATCH"); -// } -// } -// } -// } -// } - -// commented out, supplied as info on how to manipulate annotations in an -// eclipse world -// -// public void doDeclareAnnotationOnFields() { -// Collection daofs = factory.getDeclareAnnotationOnFields(); -// if (daofs!=null && daofs.size()>0 && !(sourceType instanceof -// BinaryTypeBinding)) { -// System.err.println("Going through the fields on "+sourceType.debugName()+ -// " looking for DECA matches"); -// // We better take a look through them... -// for (Iterator iter = daofs.iterator(); iter.hasNext();) { -// DeclareAnnotation element = (DeclareAnnotation) iter.next(); -// System.err.println("Processing deca "+element+" on "+sourceType.debugName()+ -// " "+getType(sourceType.compoundName).debugName()+" " -// +(sourceType instanceof BinaryTypeBinding)); -// -// ReferenceBinding rbb = getType(sourceType.compoundName); -// // fix me? should iterate the other way round, over the methods then over the -// decas -// sourceType.fields(); // resolve the bloody things -// FieldBinding sourceFbs[] = sourceType.fields; -// for (int i = 0; i < sourceFbs.length; i++) { -// FieldBinding sourceFb = sourceFbs[i]; -// //FieldBinding fbbbb = -// ((SourceTypeBinding)rbb).getgetExactMethod(sourceMb.selector -// ,sourceMb.parameters); -// -// System.err.println("Checking "+sourceFb+" ... declaringclass="+sourceFb. -// declaringClass.debugName()+" rbb="+rbb.debugName()); -// -// ResolvedMember rm = null; -// rm = EclipseFactory.makeResolvedMember(sourceFb); -// if (element.matches(rm,factory.getWorld())) { -// System.err.println("MATCH"); -// -// // Determine the set of annotations that are currently on the field -// ReferenceBinding rb = getType(sourceType.compoundName); -// // TypeBinding tb = factory.makeTypeBinding(decA.getAspect()); -// FieldBinding fb = ((SourceTypeBinding)rb).getField(sourceFb.name,true); -// //long abits = mbs[0].getAnnotationTagBits(); // ensure resolved -// TypeDeclaration typeDecl = -// ((SourceTypeBinding)sourceFb.declaringClass).scope.referenceContext; -// FieldDeclaration fd = typeDecl.declarationOf(sourceFb); -// //AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(sourceMb); -// Annotation[] currentlyHas = fd.annotations; // this is what to add -// //abits = toAdd[0].resolvedType.getAnnotationTagBits(); -// -// // Determine the annotations to add to that method -// TypeBinding tb = factory.makeTypeBinding(element.getAspect()); -// MethodBinding[] aspectMbs = -// ((SourceTypeBinding)tb).getMethods(element.getAnnotationMethod -// ().toCharArray()); -// long abits = aspectMbs[0].getAnnotationTagBits(); // ensure resolved -// TypeDeclaration typeDecl2 = -// ((SourceTypeBinding)aspectMbs[0].declaringClass).scope.referenceContext; -// AbstractMethodDeclaration methodDecl2 = -// typeDecl2.declarationOf(aspectMbs[0]); -// Annotation[] toAdd = methodDecl2.annotations; // this is what to add -// // abits = toAdd[0].resolvedType.getAnnotationTagBits(); -// System.err.println("Has: "+currentlyHas+" toAdd: "+toAdd); -// -// // fix me? check if it already has the annotation -// -// -// //Annotation abefore[] = sourceType.scope.referenceContext.annotations; -// Annotation[] newset = new -// Annotation[(currentlyHas==null?0:currentlyHas.length)+1]; -// System.arraycopy(toAdd,0,newset,0,toAdd.length); -// if (currentlyHas!=null) { -// System.arraycopy(currentlyHas,0,newset,1,currentlyHas.length); -// } -// fd.annotations = newset; -// System.err.println("New set on "+CharOperation.charToString(sourceFb.name)+ -// " is "+newset); -// } else -// System.err.println("NO MATCH"); -// } -// -// } -// } + private static boolean hasAspectDeclarations(CompilationUnitDeclaration unit) { + if (unit.types == null) + return false; + for (int j = 0; j < unit.types.length; j++) { + if (unit.types[j] instanceof AspectDeclaration) { + return true; + } + } + return false; + } + + @Override + public void reset() { + this.factory.cleanup(); + super.reset(); + } + + @Override + public LookupEnvironment wrapInModuleEnvironment(ModuleBinding moduleBinding) { + AjLookupEnvironment newAjLookupEnvironment = new AjLookupEnvironment(this, moduleBinding); + newAjLookupEnvironment.factory = this.factory; + return newAjLookupEnvironment; + } + + // Commented out, supplied as info on how to manipulate annotations in an Eclipse world +/* + public void doDeclareAnnotationOnMethods() { + // Do the declare annotation on fields/methods/ctors + Collection daoms = factory.getDeclareAnnotationOnMethods(); + if (daoms != null && daoms.size() > 0 && !(sourceType instanceof BinaryTypeBinding)) { + System.err.println("Going through the methods on " + sourceType.debugName() + + " looking for DECA matches"); + // We better take a look through them... + for (Iterator iter = daoms.iterator(); iter.hasNext(); ) { + DeclareAnnotation element = (DeclareAnnotation) iter.next(); + System.err.println("Looking for anything that might match " + element + " on " + + sourceType.debugName() + " " + getType(sourceType. + compoundName).debugName() + " " + (sourceType instanceof BinaryTypeBinding)); + + ReferenceBinding rbb = getType(sourceType.compoundName); + // Fix me, if we ever uncomment this code... should iterate the other way round, + // over the methods then over the decas + sourceType.methods(); + MethodBinding sourceMbs[] = sourceType.methods; + for (int i = 0; i < sourceMbs.length; i++) { + MethodBinding sourceMb = sourceMbs[i]; + MethodBinding mbbbb = ((SourceTypeBinding) rbb).getExactMethod(sourceMb.selector, sourceMb.parameters); + boolean isCtor = sourceMb.selector[0] == '<'; + + if ((element.isDeclareAtConstuctor() ^ !isCtor)) { + System.err.println("Checking " + sourceMb + " ... declaringclass=" + sourceMb.declaringClass.debugName() + + " rbb=" + rbb.debugName() + " " + sourceMb.declaringClass.equals(rbb)); + + ResolvedMember rm = null; + rm = EclipseFactory.makeResolvedMember(mbbbb); + if (element.matches(rm, factory.getWorld())) { + System.err.println("MATCH"); + + // Determine the set of annotations that are currently on the method + ReferenceBinding rb = getType(sourceType.compoundName); + // TypeBinding tb = factory.makeTypeBinding(decA.getAspect()); + MethodBinding mb = ((SourceTypeBinding) rb).getExactMethod(sourceMb.selector, sourceMb.parameters); + //long abits = mbs[0].getAnnotationTagBits(); // ensure resolved + TypeDeclaration typeDecl = ((SourceTypeBinding) sourceMb.declaringClass).scope.referenceContext; + AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(sourceMb); + Annotation[] currentlyHas = methodDecl.annotations; // this is what to add + //abits = toAdd[0].resolvedType.getAnnotationTagBits(); + + // Determine the annotations to add to that method + TypeBinding tb = factory.makeTypeBinding(element.getAspect()); + MethodBinding[] aspectMbs = ((SourceTypeBinding) tb).getMethods(element.getAnnotationMethod().toCharArray()); + long abits = aspectMbs[0].getAnnotationTagBits(); // ensure resolved + TypeDeclaration typeDecl2 = ((SourceTypeBinding) aspectMbs[0].declaringClass).scope.referenceContext; + AbstractMethodDeclaration methodDecl2 = typeDecl2.declarationOf(aspectMbs[0]); + Annotation[] toAdd = methodDecl2.annotations; // this is what to add + // abits = toAdd[0].resolvedType.getAnnotationTagBits(); + System.err.println("Has: " + currentlyHas + " toAdd: " + toAdd); + + // Fix me? should check if it already has the annotation + //Annotation abefore[] = sourceType.scope.referenceContext.annotations; + Annotation[] newset = new Annotation[(currentlyHas == null ? 0 : currentlyHas.length) + 1]; + System.arraycopy(toAdd, 0, newset, 0, toAdd.length); + if (currentlyHas != null) { + System.arraycopy(currentlyHas, 0, newset, 1, currentlyHas.length); + } + methodDecl.annotations = newset; + System.err.println("New set on " + CharOperation.charToString(sourceMb.selector) + " is " + newset); + } else + System.err.println("NO MATCH"); + } + } + } + } + } +*/ + + // Commented out, supplied as info on how to manipulate annotations in an Eclipse world +/* + public void doDeclareAnnotationOnFields() { + Collection daofs = factory.getDeclareAnnotationOnFields(); + if (daofs != null && daofs.size() > 0 && !(sourceType instanceof BinaryTypeBinding)) { + System.err.println("Going through the fields on " + sourceType.debugName() + " looking for DECA matches"); + // We better take a look through them... + for (Iterator iter = daofs.iterator(); iter.hasNext(); ) { + DeclareAnnotation element = (DeclareAnnotation) iter.next(); + System.err.println("Processing deca " + element + " on " + sourceType.debugName() + + " " + getType(sourceType.compoundName).debugName() + " " + + (sourceType instanceof BinaryTypeBinding)); + + ReferenceBinding rbb = getType(sourceType.compoundName); + // Fix me? should iterate the other way round, over the methods then over the decas. + sourceType.fields(); // resolve the bloody things + FieldBinding sourceFbs[] = sourceType.fields; + for (int i = 0; i < sourceFbs.length; i++) { + FieldBinding sourceFb = sourceFbs[i]; + //FieldBinding fbbbb = ((SourceTypeBinding) rbb).getgetExactMethod(sourceMb.selector, sourceMb.parameters); + + System.err.println("Checking " + sourceFb + " ... declaringclass=" + + sourceFb.declaringClass.debugName() + " rbb=" + rbb.debugName()); + + ResolvedMember rm = null; + rm = EclipseFactory.makeResolvedMember(sourceFb); + if (element.matches(rm, factory.getWorld())) { + System.err.println("MATCH"); + + // Determine the set of annotations that are currently on the field + ReferenceBinding rb = getType(sourceType.compoundName); + // TypeBinding tb = factory.makeTypeBinding(decA.getAspect()); + FieldBinding fb = ((SourceTypeBinding) rb).getField(sourceFb.name, true); + //long abits = mbs[0].getAnnotationTagBits(); // ensure resolved + TypeDeclaration typeDecl = + ((SourceTypeBinding) sourceFb.declaringClass).scope.referenceContext; + FieldDeclaration fd = typeDecl.declarationOf(sourceFb); + //AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(sourceMb); + Annotation[] currentlyHas = fd.annotations; // this is what to add + //abits = toAdd[0].resolvedType.getAnnotationTagBits(); + + // Determine the annotations to add to that method + TypeBinding tb = factory.makeTypeBinding(element.getAspect()); + MethodBinding[] aspectMbs = ((SourceTypeBinding) tb).getMethods(element.getAnnotationMethod().toCharArray()); + long abits = aspectMbs[0].getAnnotationTagBits(); // ensure resolved + TypeDeclaration typeDecl2 = ((SourceTypeBinding) aspectMbs[0].declaringClass).scope.referenceContext; + AbstractMethodDeclaration methodDecl2 = typeDecl2.declarationOf(aspectMbs[0]); + Annotation[] toAdd = methodDecl2.annotations; // this is what to add + // abits = toAdd[0].resolvedType.getAnnotationTagBits(); + System.err.println("Has: " + currentlyHas + " toAdd: " + toAdd); + + // Fix me? Check if it already has the annotation. + + //Annotation abefore[] = sourceType.scope.referenceContext.annotations; + Annotation[] newset = new + Annotation[(currentlyHas == null ? 0 : currentlyHas.length) + 1]; + System.arraycopy(toAdd, 0, newset, 0, toAdd.length); + if (currentlyHas != null) { + System.arraycopy(currentlyHas, 0, newset, 1, currentlyHas.length); + } + fd.annotations = newset; + System.err.println("New set on " + CharOperation.charToString(sourceFb.name) + " is " + newset); + } else + System.err.println("NO MATCH"); + } + } + } + } +*/ + +} From 73b36b1a2532cc33e746c3ccf751713d875897f1 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 1 Oct 2023 13:46:30 +0700 Subject: [PATCH 08/29] AntSpec: Improve filter for warning "Archived non-system classes are disabled" In JDK 21, the prefix has changed once again, no longer being a JVM specifier like "OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit Server VM" but rather something like "[0.016s][warning][cds]". Even worse, before J21, the warning appears on stdErr, but in J21+, it appears on stdOut. Fixes LTWTests.testJ14LTWWithXML, which started failing on Java 21. Signed-off-by: Alexander Kriegisch --- .../test/java/org/aspectj/testing/AntSpec.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/testing/src/test/java/org/aspectj/testing/AntSpec.java b/testing/src/test/java/org/aspectj/testing/AntSpec.java index 9d239d61b..07f2f10ff 100644 --- a/testing/src/test/java/org/aspectj/testing/AntSpec.java +++ b/testing/src/test/java/org/aspectj/testing/AntSpec.java @@ -212,9 +212,19 @@ public void messageLogged(BuildEvent event) { AjcTestCase.fail(failMessage + "error when invoking target :" + t.toString()); } + // J12: Line can start with e.g. "OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit Server VM". + // J21: Line can start with e.g. "[0.016s][warning][cds]". + // Therefore, we have to match a substring instead of a whole line. + // Even worse, before J21, the warning appears on stdErr, but in J21+, it appears on stdOut. + final String regexArchivedNonSystemClasses = "[^\n]+( warning:|\\[warning]\\[cds]) " + + "Archived non-system classes are disabled because the java.system.class.loader property is specified " + + ".*org.aspectj.weaver.loadtime.WeavingURLClassLoader[^\n]+\n?"; + /* See if stdout/stderr matches test specification */ if (m_stdOutSpec != null) { - m_stdOutSpec.matchAgainst(stdout.toString()); + String stdout2 = stdout.toString(); + stdout2 = stdout2.replaceAll(regexArchivedNonSystemClasses, ""); + m_stdOutSpec.matchAgainst(stdout2); } if (m_stdErrSpec != null) { String stderr2 = stderr.toString(); @@ -236,9 +246,7 @@ public void messageLogged(BuildEvent event) { stderr2 = stderr2.replaceAll("WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\n",""); stderr2 = stderr2.replaceAll("WARNING: All illegal access operations will be denied in a future release\n",""); } - // J12: Line can start with e.g."OpenJDK 64-Bit Server VM" or "Java HotSpot(TM) 64-Bit Server VM". Therefore, - // we have to match a substring instead of a whole line - stderr2 = stderr2.replaceAll("[^\n]+ warning: Archived non-system classes are disabled because the java.system.class.loader property is specified .*org.aspectj.weaver.loadtime.WeavingURLClassLoader[^\n]+\n?",""); + stderr2 = stderr2.replaceAll(regexArchivedNonSystemClasses, ""); m_stdErrSpec.matchAgainst(stderr2); } } From 19a414b7153c05197ac7d6c74dd3de969cf4a349 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 07:17:06 +0700 Subject: [PATCH 09/29] Bump ASM to 9.6 (new Opcodes.V22 constant for Java 22) Signed-off-by: Alexander Kriegisch --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3ca99b8a6..1ea0bc1bd 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 1.9.21-SNAPSHOT - 9.5 + 9.6 1.6.3 2.6.2 1.2 From 3533dcd043ca31e6988fae714882328d23543a65 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 08:00:47 +0700 Subject: [PATCH 10/29] Beautify sanity tests using bytecode level constants Signed-off-by: Alexander Kriegisch --- .../org/aspectj/systemtest/ajc160/SanityTests.java | 10 ++++++---- .../org/aspectj/systemtest/ajc190/SanityTests19.java | 8 +++++--- .../aspectj/systemtest/ajc191/SanityTestsJava10.java | 8 +++++--- .../aspectj/systemtest/ajc1919/SanityTestsJava19.java | 5 +++-- .../aspectj/systemtest/ajc192/SanityTestsJava11.java | 8 +++++--- .../aspectj/systemtest/ajc1920/SanityTestsJava20.java | 5 +++-- .../aspectj/systemtest/ajc195/SanityTestsJava13.java | 5 +++-- .../aspectj/systemtest/ajc196/SanityTestsJava14.java | 5 +++-- .../aspectj/systemtest/ajc197/SanityTestsJava15.java | 5 +++-- .../aspectj/systemtest/ajc197/SanityTestsJava16.java | 5 +++-- .../aspectj/systemtest/ajc198/SanityTestsJava17.java | 5 +++-- .../aspectj/systemtest/ajc199/SanityTestsJava18.java | 5 +++-- 12 files changed, 45 insertions(+), 29 deletions(-) diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java index 224e3e599..4a7c39a01 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc160; +import org.aspectj.apache.bcel.Constants; import org.aspectj.apache.bcel.classfile.Attribute; import org.aspectj.apache.bcel.classfile.Code; import org.aspectj.apache.bcel.classfile.JavaClass; @@ -25,6 +26,7 @@ * rather than executing them. */ public class SanityTests extends org.aspectj.testing.XMLBasedAjcTestCase { + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_1_6; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -66,22 +68,22 @@ public void testSimpleCode_I() { // Check the version number in the classfiles is correct when Java6 options specified public void testVersionCorrect1() throws ClassNotFoundException { runTest("simple - j"); - checkVersion("A", 50, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect2() throws ClassNotFoundException { runTest("simple - k"); - checkVersion("A", 50, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect3() throws ClassNotFoundException { runTest("simple - l"); - checkVersion("A", 50, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect4() throws ClassNotFoundException {// check it is 49.0 when -1.5 is specified runTest("simple - m"); - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } // Check the stackmap stuff appears for methods in a Java6 file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java index c42a0cc25..ac5b109e6 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc190/SanityTests19.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc190; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import junit.framework.Test; @@ -20,6 +21,7 @@ * to check code generation and modification with that version specified. */ public class SanityTests19 extends org.aspectj.testing.XMLBasedAjcTestCase { + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_1_9; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -61,17 +63,17 @@ public void testSimpleCode_I() { // Check the version number in the classfiles is correct when Java6 options specified public void testVersionCorrect1() throws ClassNotFoundException { runTest("simple - j"); - checkVersion("A", 53, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect2() throws ClassNotFoundException { runTest("simple - k"); - checkVersion("A", 53, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified runTest("simple - m"); - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } // Check the stackmap stuff appears for methods in a Java6 file diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java index d5505a252..5d5a04564 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc191/SanityTestsJava10.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc191; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import junit.framework.Test; @@ -19,6 +20,7 @@ * @author Andy Clement */ public class SanityTestsJava10 extends org.aspectj.testing.XMLBasedAjcTestCase { + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_10; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -59,17 +61,17 @@ public void testSimpleCode_I() { public void testVersionCorrect1() throws ClassNotFoundException { runTest("simple - j"); - checkVersion("A", 54, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect2() throws ClassNotFoundException { runTest("simple - k"); - checkVersion("A", 54, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified runTest("simple - m"); - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } // /////////////////////////////////////// diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java index fa2abafe5..a8a3826ea 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc1919; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater { - public static final int bytecode_version_for_JDK_level = 63; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_19; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java index 329b3f880..b0f2cdb67 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc192/SanityTestsJava11.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc192; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater; @@ -20,6 +21,7 @@ * @author Andy Clement */ public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater { + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_11; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -60,17 +62,17 @@ public void testSimpleCode_I() { public void testVersionCorrect1() throws ClassNotFoundException { runTest("simple - j"); - checkVersion("A", 55, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect2() throws ClassNotFoundException { runTest("simple - k"); - checkVersion("A", 55, 0); + checkVersion("A", bytecode_version_for_JDK_level, 0); } public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified runTest("simple - m"); - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java index 09f52c1b7..88b9670e9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc1920; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava20OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava20 extends XMLBasedAjcTestCaseForJava20OrLater { - public static final int bytecode_version_for_JDK_level = 64; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_20; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java index f8cffca69..54397cf2f 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc195; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava13OrLater; @@ -21,7 +22,7 @@ */ public class SanityTestsJava13 extends XMLBasedAjcTestCaseForJava13OrLater { - public static final int bytecode_version_for_JDK_level = 57; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_13; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() throws ClassNotFoundException { public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified runTest("simple - m"); - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java index 6857b4d8a..960ba4420 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java @@ -7,6 +7,7 @@ *******************************************************************************/ package org.aspectj.systemtest.ajc196; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava14OrLater; @@ -21,7 +22,7 @@ */ public class SanityTestsJava14 extends XMLBasedAjcTestCaseForJava14OrLater { - public static final int bytecode_version_for_JDK_level = 58; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_14; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -73,7 +74,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java index 9622e7364..a7ee41d5f 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc197; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater { - public static final int bytecode_version_for_JDK_level = 59; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_15; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java index 52950b4dd..185660b15 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc197; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater { - public static final int bytecode_version_for_JDK_level = 60; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_16; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java index 0769be83b..a9c247dad 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc198; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater { - public static final int bytecode_version_for_JDK_level = 61; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_17; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java index 2fd9d2660..a4c8ee9e2 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc199; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater; @@ -20,7 +21,7 @@ */ public class SanityTestsJava18 extends XMLBasedAjcTestCaseForJava18OrLater { - public static final int bytecode_version_for_JDK_level = 62; + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_18; // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) public void testSimpleJava_A() { @@ -72,7 +73,7 @@ public void testVersionCorrect2() { public void testVersionCorrect4() { runTest("simple - m"); // Must be 49.0 when -1.5 is specified - checkVersion("A", 49, 0); + checkVersion("A", Constants.MAJOR_1_5, 0); } public static Test suite() { From 78ee9cebd81f1496d69bd0c933e3ee16fa02a96f Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 08:09:24 +0700 Subject: [PATCH 11/29] Add test infrastructure for Java 21 (WIP) The tests and their XML definitions are still copy & paste and need to be cleaned up. Separate Java 21 feature tests do not exist yet. Signed-off-by: Alexander Kriegisch --- .../org/aspectj/apache/bcel/Constants.java | 6 +- .../aspectj/tools/ant/taskdefs/AjcTask.java | 6 +- .../XMLBasedAjcTestCaseForJava20Only.java | 4 +- .../XMLBasedAjcTestCaseForJava21Only.java | 40 ++ .../XMLBasedAjcTestCaseForJava21OrLater.java | 27 + .../ajc1920/AllTestsAspectJ1920.java | 3 +- .../ajc1920/Java20PreviewFeaturesTests.java | 2 +- .../systemtest/ajc1921/Ajc1921TestsJava.java | 32 ++ .../ajc1921/AllTestsAspectJ1921.java | 33 ++ .../systemtest/ajc1921/Bugs1921Tests.java | 100 ++++ .../ajc1921/Java21PreviewFeaturesTests.java | 103 ++++ .../systemtest/ajc1921/SanityTestsJava21.java | 88 ++++ .../aspectj/systemtest/ajc1920/ajc1920.xml | 2 +- .../aspectj/systemtest/ajc1921/ajc1921.xml | 478 ++++++++++++++++++ .../systemtest/ajc1921/sanity-tests-21.xml | 70 +++ .../main/java/org/aspectj/util/LangUtil.java | 4 + 16 files changed, 988 insertions(+), 10 deletions(-) create mode 100644 testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java create mode 100644 testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java create mode 100644 tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml create mode 100644 tests/src/test/resources/org/aspectj/systemtest/ajc1921/sanity-tests-21.xml diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java index 216bdfdde..77477747c 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java @@ -104,8 +104,10 @@ public interface Constants { short MINOR_19 = 0; short MAJOR_20 = 64; short MINOR_20 = 0; -// short MAJOR_21 = 65; -// short MINOR_21 = 0; + short MAJOR_21 = 65; + short MINOR_21 = 0; +// short MAJOR_22 = 66; +// short MINOR_22 = 0; int PREVIEW_MINOR_VERSION = 65535; diff --git a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java index 23905d45d..ab99fd670 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -252,15 +252,15 @@ public String toString() { static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21" }; static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21" }; static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", - "-10", "-11", "-12", "-13", "-14", "-15", "-16", "-17", "-18", "-19", "-20" + "-10", "-11", "-12", "-13", "-14", "-15", "-16", "-17", "-18", "-19", "-20", "-21" }; private static final ICommandEditor COMMAND_EDITOR; diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java index aeb1152fd..4e0567d0d 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java @@ -20,14 +20,13 @@ public abstract class XMLBasedAjcTestCaseForJava20Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { // Activate this block after upgrading to JDT Core Java 21 - /* throw new IllegalStateException( "These tests need a Java 20 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); - */ // Activate this block before upgrading to JDT Core Java 21 + /* if (!LangUtil.is20VMOrGreater() || LangUtil.is21VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 20 only " + @@ -35,6 +34,7 @@ public void setUp() throws Exception { ); } super.setUp(); + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java new file mode 100644 index 000000000..fb6795b3d --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21Only.java @@ -0,0 +1,40 @@ +/* ******************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava21Only extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 22 + /* + throw new IllegalStateException( + "These tests need a Java 21 level AspectJ compiler " + + "(e.g. because they use version-specific preview features). " + + "This compiler does not support preview features of a previous version anymore." + ); + */ + // Activate this block before upgrading to JDT Core Java 22 + if (!LangUtil.is21VMOrGreater() || LangUtil.is22VMOrGreater()) { + throw new IllegalStateException( + "These tests should be run on Java 21 only " + + "(e.g. because they use version-specific preview features)" + ); + } + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java new file mode 100644 index 000000000..4c1d59d15 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava21OrLater.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava21OrLater extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + if (!LangUtil.is21VMOrGreater()) + throw new IllegalStateException("These tests should be run on Java 21 or later"); + super.setUp(); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java index c7962c2db..a095eb758 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java @@ -24,10 +24,11 @@ public static Test suite() { suite.addTest(Ajc1920TestsJava.suite()); } // Do not run tests using a previous compiler's preview features anymore. They would all fail. - // TODO: Comment out the following block when upgrading JDT Core to Java 20 + /* if (LangUtil.is20VMOrGreater() && !LangUtil.is21VMOrGreater()) { suite.addTest(Java20PreviewFeaturesTests.suite()); } + */ return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java index e597b32ec..89a0a61c6 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java @@ -52,7 +52,7 @@ public void testRecordPatternsPreview1OK() { } public void testRecordPatternsPreview1Error() { - // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2033-03, 4.27) + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27) runTest("record patterns error"); checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION); checkVersion("Box", Constants.MAJOR_20, Constants.PREVIEW_MINOR_VERSION); diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java new file mode 100644 index 000000000..e7d3b9596 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1921; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater { + + public void testDummyJava21() { + //runTest("dummy Java 21"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1921TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1921.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java new file mode 100644 index 000000000..773ac9037 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/AllTestsAspectJ1921.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1921; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.util.LangUtil; + +/** + * @author Alexander Kriegisch + */ +public class AllTestsAspectJ1921 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.21 tests"); + suite.addTest(Bugs1921Tests.suite()); + if (LangUtil.is21VMOrGreater()) { + suite.addTest(SanityTestsJava21.suite()); + suite.addTest(Ajc1921TestsJava.suite()); + } + // Do not run tests using a previous compiler's preview features anymore. They would all fail. + // TODO: Comment out the following block when upgrading JDT Core to Java 22 + if (LangUtil.is21VMOrGreater() && !LangUtil.is22VMOrGreater()) { + suite.addTest(Java21PreviewFeaturesTests.suite()); + } + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java new file mode 100644 index 000000000..3c11149d3 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1921; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Alexander Kriegisch + */ +public class Bugs1921Tests extends XMLBasedAjcTestCase { + + public void testSwitchWith_Integer_MAX_VALUE() { + runTest("switch with Integer.MAX_VALUE case"); + } + + public void testParenthesisedExpressionWithAjKeyword() { + runTest("parenthesised expression with AspectJ keyword"); + } + + public void testInterfaceInnerAspectImplicitlyStatic() { + runTest("inner aspect of interface is implicitly static"); + } + + public void testExactArrayTypeMatchCompiledTogether() { + runTest("exact array type matching, aspect compiled together with target class"); + } + + public void testExactArrayTypeMatchCompiledSeparately() { + runTest("exact array type matching, aspect compiled separately from target class"); + } + + public void testFuzzyArrayTypeMatchCompiledTogether() { + runTest("fuzzy array type matching, aspect compiled together with target class"); + } + + public void testFuzzyArrayTypeMatchCompiledSeparately() { + runTest("fuzzy array type matching, aspect compiled separately from target class"); + } + + public void test_GitHub_214() { + runTest("ArrayIndexOutOfBoundsException with Xlint unorderedAdviceAtShadow=warning"); + } + + /** + * Add correct annotations to multiple ITD methods with the same name and same number of arguments, i.e. copy the + * annotations correctly from the aspect into the target class instead of falsely always copying the annotations (if + * any) from the first ITD method found. + *

+ * See GitHub issue 246. + */ + public void test_GitHub_246() { + runTest("add correct annotations to multiple ITD methods with the same name and same number of arguments"); + } + + /** + * Make sure to create one {@code ajc$inlineAccessMethod} for identically named (overloaded) private aspect methods. + *

+ * See GitHub issue 250. + */ + public void test_GitHub_250() { + runTest("correctly handle overloaded private methods in aspects"); + } + + /** + * If one generic method overrides another one with a narrower return type, avoid matching bridge methods. + *

+ * See Spring GitHub issue 27761. + *

+ * This test uses an ASM-modified class file reproducing the problem seen in Spring in plain AspectJ. Before the + * bugfix, it fails with "advice defined in RepositoryAspect has not been applied [Xlint:adviceDidNotMatch]". + */ + public void test_Spring_GitHub_27761() { + runTest("do not match bridge methods"); + } + + /** + * In 1.9.20, a regression bug occurred, matching negated types like '!void' and '!String' incorrectly. + *

+ * See GitHub issue 257. + */ + public void test_GitHub_257() { + runTest("handle negated type patterns correctly"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Bugs1921Tests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1921.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java new file mode 100644 index 000000000..1088aac63 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1921; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava21Only; + +/** + * @author Alexander Kriegisch + */ +public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only { + + public void testSwitchPatternMatchingPreview4Java() { + runTest("switch pattern matching preview 4 java"); + checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingPreview4Error() { + runTest("switch pattern matching preview 4 error"); + } + + public void testSwitchPatternMatchingPreview3Aspect() { + runTest("switch pattern matching preview 3 aspect"); + checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); + } + + public void testSwitchPatternMatchingPreview3Error1() { + runTest("switch pattern matching preview 3 error 1"); + } + + public void testSwitchPatternMatchingPreview3Error2() { + runTest("switch pattern matching preview 3 error 2"); + } + + public void testRecordPatternsPreview1OK() { + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns"); + } + + public void testRecordPatternsPreview1Error() { + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27) + runTest("record patterns error"); + checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Box", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); + } + + public void testRecordPatternsPreview1ExhaustivenessOK1() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: Remove redundant default clauses when fixed upstream + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness 1"); + } + + public void testRecordPatternsPreview1Aspect() { + runTest("record patterns aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessAspect() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: Remove redundant default clauses when fixed upstream + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessError() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + runTest("record patterns exhaustiveness error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK2() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); + //runTest("record patterns exhaustiveness 2"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java21PreviewFeaturesTests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1921.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java new file mode 100644 index 000000000..ed2216fdb --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/SanityTestsJava21.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2023 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1921; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -21 option + * to check code generation and modification with that version specified. + * + * @author Alexander Kriegisch + */ +public class SanityTestsJava21 extends XMLBasedAjcTestCaseForJava21OrLater { + + public static final int bytecode_version_for_JDK_level = Constants.MAJOR_21; + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + public void testVersionCorrect1() { + runTest("simple - j"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect2() { + runTest("simple - k"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect4() { + runTest("simple - m"); + // Must be 49.0 when -1.5 is specified + checkVersion("A", Constants.MAJOR_1_5, 0); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava21.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("sanity-tests-21.xml"); + } + +} diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml index 86fa7db02..1d25a176a 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml @@ -105,7 +105,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/sanity-tests-21.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/sanity-tests-21.xml new file mode 100644 index 000000000..e7da49fa1 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/sanity-tests-21.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 97676ea84..43d100165 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -191,6 +191,10 @@ public static boolean is21VMOrGreater() { return 21 <= vmVersion; } + public static boolean is22VMOrGreater() { + return 22 <= vmVersion; + } + /** * Shorthand for "if null, throw IllegalArgumentException" * From 39c5da6eb973ce31ad90c30c1b4156988d6b9bf8 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 11:22:13 +0700 Subject: [PATCH 12/29] AjcTestCase: Make sure main methods can be called in Java 21 Since JDK 21, a public main method of a non-public (e.g. default-scoped) class can no longer be invoked without making it accessible first. Because many test sources contain multiple aspects and classes in one file, this is a frequent use case. Signed-off-by: Alexander Kriegisch --- .../src/test/java/org/aspectj/tools/ajc/AjcTestCase.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java index e50ea9757..9aec7d947 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjcTestCase.java @@ -759,8 +759,11 @@ else if ( Thread.currentThread().setContextClassLoader(sandboxLoader); Class toRun = sandboxLoader.loadClass(className); - Method mainMethod = toRun.getMethod("main", new Class[] { String[].class }); - + Method mainMethod = toRun.getMethod("main", String[].class); + // Since JDK 21, a public main method of a non-public (e.g. default-scoped) class can no longer be invoked without + // making it accessible first. Because many test sources contain multiple aspects and classes in one file, this is + // a frequent use case. + mainMethod.setAccessible(true); mainMethod.invoke(null, new Object[] { args }); } catch (ClassNotFoundException cnf) { fail("Can't find class: " + className); From 99f426e351b62310ce3c31348594b106a4bf624e Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 11:24:28 +0700 Subject: [PATCH 13/29] Move some 1.9.20.1 bug tests to correct directory Signed-off-by: Alexander Kriegisch --- .../github_257}/NegatedTypeAspect.aj | 0 .../github_spring_27761}/JpaRepositoryDump.java | 0 .../github_spring_27761}/RepositoryAspect.aj | 0 .../org/aspectj/systemtest/ajc1920/Bugs1920Tests.java | 3 ++- .../org/aspectj/systemtest/ajc1920/ajc1920.xml | 11 +++++++---- 5 files changed, 9 insertions(+), 5 deletions(-) rename tests/{bugs1921/gh_257 => bugs1920/github_257}/NegatedTypeAspect.aj (100%) rename tests/{bugs1921/gh_spring_27761 => bugs1920/github_spring_27761}/JpaRepositoryDump.java (100%) rename tests/{bugs1921/gh_spring_27761 => bugs1920/github_spring_27761}/RepositoryAspect.aj (100%) diff --git a/tests/bugs1921/gh_257/NegatedTypeAspect.aj b/tests/bugs1920/github_257/NegatedTypeAspect.aj similarity index 100% rename from tests/bugs1921/gh_257/NegatedTypeAspect.aj rename to tests/bugs1920/github_257/NegatedTypeAspect.aj diff --git a/tests/bugs1921/gh_spring_27761/JpaRepositoryDump.java b/tests/bugs1920/github_spring_27761/JpaRepositoryDump.java similarity index 100% rename from tests/bugs1921/gh_spring_27761/JpaRepositoryDump.java rename to tests/bugs1920/github_spring_27761/JpaRepositoryDump.java diff --git a/tests/bugs1921/gh_spring_27761/RepositoryAspect.aj b/tests/bugs1920/github_spring_27761/RepositoryAspect.aj similarity index 100% rename from tests/bugs1921/gh_spring_27761/RepositoryAspect.aj rename to tests/bugs1920/github_spring_27761/RepositoryAspect.aj diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java index b1942f11b..a87230f90 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java @@ -70,7 +70,8 @@ public void test_GitHub_250() { /** * If one generic method overrides another one with a narrower return type, avoid matching bridge methods. *

- * See Spring GitHub issue 27761. + * See Spring GitHub issue 27761, + * AspectJ GitHub issue 257. *

* This test uses an ASM-modified class file reproducing the problem seen in Spring in plain AspectJ. Before the * bugfix, it fails with "advice defined in RepositoryAspect has not been applied [Xlint:adviceDidNotMatch]". diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml index 1d25a176a..98a255088 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml @@ -418,8 +418,11 @@ - - + + @@ -434,8 +437,8 @@ - - + + From 72171c3724100618bf2c733316d23ff7578eeaa1 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 5 Oct 2023 11:29:04 +0700 Subject: [PATCH 14/29] Make all existing tests run on JDK 21 This mostly affects pattern matching for switch and record patterns. Two tests which were working before for pattern matching for switch (preview 4), started to fail, so the corresponding code was commented out and https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 recorded. Signed-off-by: Alexander Kriegisch --- .../java21/SwitchPatternPreview3Aspect.aj | 97 +++++ .../java21/SwitchPatternPreview4OK.java | 157 +++++++ .../systemtest/ajc1921/Ajc1921TestsJava.java | 75 +++- .../systemtest/ajc1921/Bugs1921Tests.java | 73 +--- .../ajc1921/Java21PreviewFeaturesTests.java | 75 +--- .../aspectj/systemtest/ajc1921/ajc1921.xml | 404 +++--------------- 6 files changed, 393 insertions(+), 488 deletions(-) create mode 100644 tests/features1921/java21/SwitchPatternPreview3Aspect.aj create mode 100644 tests/features1921/java21/SwitchPatternPreview4OK.java diff --git a/tests/features1921/java21/SwitchPatternPreview3Aspect.aj b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj new file mode 100644 index 000000000..cab9a2bcd --- /dev/null +++ b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj @@ -0,0 +1,97 @@ +import java.util.List; +import java.util.Locale; + +aspect SwitchPatternPreview3Aspect { + Object around(Object o) : execution(* doSomethingWithObject(*)) && args(o) { + System.out.println(switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }); + return proceed(o); + } + + before(Shape s) : execution(* doSomethingWithShape(*)) && args(s) { + System.out.println(switch (s) { + case Circle c when (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }); + } + + after(S s) : execution(* doSomethingWithSealedClass(*)) && args(s) { + System.out.println(switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }); + } + + Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { + // This used to work in preview 4 (Java 20), but fails during runtime with + // java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 + // in ECJ 3.36.0-SNAPSHOT with Java 21. + // See: + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. + // + // TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. + /* + System.out.println( + switch (i) { + case null -> "value unavailable: " + i; + case -1, 1 -> "absolute value 1: " + i; + case Integer value when value > 0 -> "positive integer: " + i; + default -> "other integer: " + i; + } + ); + */ + return proceed(i); + } +} + +class Shape {} +class Rectangle extends Shape {} +class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } +} + +sealed interface S permits A, B, C {} +final class A implements S {} +final class B implements S {} +record C(int i) implements S {} // Implicitly final + +class Application { + public static void main(String[] args) { + doSomethingWithObject(null); + doSomethingWithObject(123); + doSomethingWithObject(999L); + doSomethingWithObject(12.34); + doSomethingWithObject("foo"); + doSomethingWithObject(List.of(123, "foo", 999L, 12.34)); + + doSomethingWithShape(new Rectangle()); + doSomethingWithShape(new Circle(5)); + doSomethingWithShape(new Circle(6)); + + doSomethingWithSealedClass(new A()); + doSomethingWithSealedClass(new B()); + doSomethingWithSealedClass(new C(5)); + + doSomethingWithInteger(-1); + doSomethingWithInteger(0); + doSomethingWithInteger(42); + doSomethingWithInteger(-99); + doSomethingWithInteger(Integer.valueOf(123)); + doSomethingWithInteger(null); + } + + public static Object doSomethingWithObject(Object o) { return o; } + public static void doSomethingWithSealedClass(S s) {} + public static void doSomethingWithShape(Shape s) {} + public static Object doSomethingWithInteger(Integer o) { return o; } +} diff --git a/tests/features1921/java21/SwitchPatternPreview4OK.java b/tests/features1921/java21/SwitchPatternPreview4OK.java new file mode 100644 index 000000000..c9caf7eca --- /dev/null +++ b/tests/features1921/java21/SwitchPatternPreview4OK.java @@ -0,0 +1,157 @@ +import java.util.List; +import java.util.Locale; + +/** + * Inspired by examples in https://openjdk.org/jeps/427 + */ +public class SwitchPatternPreview4OK { + public static void main(String[] args) { + + System.out.println(formatterPatternSwitch(null)); + System.out.println(formatterPatternSwitch(123)); + System.out.println(formatterPatternSwitch(999L)); + System.out.println(formatterPatternSwitch(12.34)); + System.out.println(formatterPatternSwitch("foo")); + System.out.println(formatterPatternSwitch(List.of(123, "foo", 999L, 12.34))); + + System.out.println(testCircle(new Rectangle())); + System.out.println(testCircle(new Circle(5))); + System.out.println(testCircle(new Circle(6))); + + System.out.println(testSealedCoverage(new A())); + System.out.println(testSealedCoverage(new B())); + System.out.println(testSealedCoverage(new C(5))); + +// constantLabelMustAppearBeforePattern(-1); +// constantLabelMustAppearBeforePattern(0); +// constantLabelMustAppearBeforePattern(42); +// constantLabelMustAppearBeforePattern(-99); +// constantLabelMustAppearBeforePattern(Integer.valueOf(123)); +// constantLabelMustAppearBeforePattern(null); + + // TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. + /* + constantLabelMustAppearBeforePatternInteger(-1); + constantLabelMustAppearBeforePatternInteger(0); + constantLabelMustAppearBeforePatternInteger(42); + constantLabelMustAppearBeforePatternInteger(-99); + constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); + constantLabelMustAppearBeforePatternInteger(null); + */ + + System.out.println(testGenericSealedExhaustive(new E())); + } + + static String formatterPatternSwitch(Object o) { + return switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + static class Shape {} + static class Rectangle extends Shape {} + static class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } + } + + static String testCircle(Shape s) { + return switch (s) { + case Circle c when (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }; + } + + sealed interface S permits A, B, C {} + final static class A implements S {} + final static class B implements S {} + static record C(int i) implements S {} // Implicitly final + + static String testSealedCoverage(S s) { + return switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }; + } + + /** + * According to an example from JEP 420, this should work, but it does not, neither with Javac nor ECJ. + * + * See: + * https://openjdk.java.net/jeps/420#1b--Dominance-of-pattern-labels + * https://bugs.openjdk.java.net/browse/JDK-8273326 + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=579355 + * + * TODO: reactivate when implemented or move to preview 5 with Java 21, Eclipse 4.28. + */ +/* + static String constantLabelMustAppearBeforePattern(Object o) { + switch (o) { + case null -> System.out.println("value unavailable: " + o); + case -1, 1 -> System.out.println("special case:" + o); + case Integer value when value > 0 -> System.out.println("positive integer: " + o); + case Integer i -> System.out.println("other integer: " + o); + default -> System.out.println("non-integer: " + o); + } + return o == null ? "null" : o.toString(); + } +*/ + + /** + * This used to work in preview 4 (Java 20), but fails during runtime with + * java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 + * in ECJ 3.36.0-SNAPSHOT with Java 21. + * See: + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. + * + * TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. + */ + static String constantLabelMustAppearBeforePatternInteger(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + default -> System.out.println("other integer: " + i); + } + return i == null ? "null" : i.toString(); + } + + static void nullCanAppearAfterConstantLabel(Integer i) { + switch (i) { + case -1, 1 -> System.out.println("absolute value 1: " + i); + case null -> System.out.println("value unavailable: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + default -> System.out.println("other integer: " + i); + } + } + + /** + * According to an example from JEP 420, this should work with preview 2 (Java 18), and it does with Javac, + * but not with ECJ for Java 18, 19 and 20. + * + * See: + * https://openjdk.java.net/jeps/420#2--Exhaustiveness-of-switch-expressions-and-statements + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=579360 + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/587 + * + * TODO: reactivate when implemented or move to preview 5 with Java 21. + */ + sealed interface I permits D, E {} + final static class D implements I {} + final static class E implements I {} + + static int testGenericSealedExhaustive(I i) { + return switch (i) { + // Exhaustive as no D case possible! + case E bi -> 42; + }; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java index e7d3b9596..20efe1723 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java @@ -8,6 +8,7 @@ package org.aspectj.systemtest.ajc1921; import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater; @@ -16,8 +17,78 @@ */ public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater { - public void testDummyJava21() { - //runTest("dummy Java 21"); + public void testSwitchPatternMatchingPreview4Java() { + runTest("switch pattern matching preview 4 java"); + checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_21, Constants.MINOR_21); + } + + public void testSwitchPatternMatchingPreview4Error() { + runTest("switch pattern matching preview 4 error"); + } + + public void testSwitchPatternMatchingPreview3Aspect() { + runTest("switch pattern matching preview 3 aspect"); + checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_21, Constants.MINOR_21); + checkVersion("Application", Constants.MAJOR_21, Constants.MINOR_21); + checkVersion("Shape", Constants.MAJOR_21, Constants.MINOR_21); + checkVersion("S", Constants.MAJOR_21, Constants.MINOR_21); + } + + public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); + } + + public void testSwitchPatternMatchingPreview3Error1() { + runTest("switch pattern matching preview 3 error 1"); + } + + public void testSwitchPatternMatchingPreview3Error2() { + runTest("switch pattern matching preview 3 error 2"); + } + + public void testRecordPatternsPreview1OK() { + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns"); + } + + public void testRecordPatternsPreview1Error() { + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27) + runTest("record patterns error"); + checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_21, Constants.MINOR_21); + checkVersion("Box", Constants.MAJOR_21, Constants.MINOR_21); + } + + public void testRecordPatternsPreview1ExhaustivenessOK1() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: Remove redundant default clauses when fixed upstream + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness 1"); + } + + public void testRecordPatternsPreview1Aspect() { + runTest("record patterns aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessAspect() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: Remove redundant default clauses when fixed upstream + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessError() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + runTest("record patterns exhaustiveness error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK2() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); + //runTest("record patterns exhaustiveness 2"); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java index 3c11149d3..113731a4f 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java @@ -15,77 +15,8 @@ */ public class Bugs1921Tests extends XMLBasedAjcTestCase { - public void testSwitchWith_Integer_MAX_VALUE() { - runTest("switch with Integer.MAX_VALUE case"); - } - - public void testParenthesisedExpressionWithAjKeyword() { - runTest("parenthesised expression with AspectJ keyword"); - } - - public void testInterfaceInnerAspectImplicitlyStatic() { - runTest("inner aspect of interface is implicitly static"); - } - - public void testExactArrayTypeMatchCompiledTogether() { - runTest("exact array type matching, aspect compiled together with target class"); - } - - public void testExactArrayTypeMatchCompiledSeparately() { - runTest("exact array type matching, aspect compiled separately from target class"); - } - - public void testFuzzyArrayTypeMatchCompiledTogether() { - runTest("fuzzy array type matching, aspect compiled together with target class"); - } - - public void testFuzzyArrayTypeMatchCompiledSeparately() { - runTest("fuzzy array type matching, aspect compiled separately from target class"); - } - - public void test_GitHub_214() { - runTest("ArrayIndexOutOfBoundsException with Xlint unorderedAdviceAtShadow=warning"); - } - - /** - * Add correct annotations to multiple ITD methods with the same name and same number of arguments, i.e. copy the - * annotations correctly from the aspect into the target class instead of falsely always copying the annotations (if - * any) from the first ITD method found. - *

- * See GitHub issue 246. - */ - public void test_GitHub_246() { - runTest("add correct annotations to multiple ITD methods with the same name and same number of arguments"); - } - - /** - * Make sure to create one {@code ajc$inlineAccessMethod} for identically named (overloaded) private aspect methods. - *

- * See GitHub issue 250. - */ - public void test_GitHub_250() { - runTest("correctly handle overloaded private methods in aspects"); - } - - /** - * If one generic method overrides another one with a narrower return type, avoid matching bridge methods. - *

- * See Spring GitHub issue 27761. - *

- * This test uses an ASM-modified class file reproducing the problem seen in Spring in plain AspectJ. Before the - * bugfix, it fails with "advice defined in RepositoryAspect has not been applied [Xlint:adviceDidNotMatch]". - */ - public void test_Spring_GitHub_27761() { - runTest("do not match bridge methods"); - } - - /** - * In 1.9.20, a regression bug occurred, matching negated types like '!void' and '!String' incorrectly. - *

- * See GitHub issue 257. - */ - public void test_GitHub_257() { - runTest("handle negated type patterns correctly"); + public void testDummy() { + //runTest("dummy"); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java index 1088aac63..4b4de845d 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java @@ -8,7 +8,6 @@ package org.aspectj.systemtest.ajc1921; import junit.framework.Test; -import org.aspectj.apache.bcel.Constants; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.testing.XMLBasedAjcTestCaseForJava21Only; @@ -17,78 +16,8 @@ */ public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only { - public void testSwitchPatternMatchingPreview4Java() { - runTest("switch pattern matching preview 4 java"); - checkVersion("SwitchPatternPreview4OK", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - } - - public void testSwitchPatternMatchingPreview4Error() { - runTest("switch pattern matching preview 4 error"); - } - - public void testSwitchPatternMatchingPreview3Aspect() { - runTest("switch pattern matching preview 3 aspect"); - checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - checkVersion("Application", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - checkVersion("Shape", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - checkVersion("S", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - } - - public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { - runTest("switch pattern matching error"); - } - - public void testSwitchPatternMatchingPreview3Error1() { - runTest("switch pattern matching preview 3 error 1"); - } - - public void testSwitchPatternMatchingPreview3Error2() { - runTest("switch pattern matching preview 3 error 2"); - } - - public void testRecordPatternsPreview1OK() { - // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 - runTest("record patterns"); - } - - public void testRecordPatternsPreview1Error() { - // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 (fixed for preview 2 in Eclipse 2023-03, 4.27) - runTest("record patterns error"); - checkVersion("RecordPatternsPreview1Error", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - checkVersion("Box", Constants.MAJOR_21, Constants.PREVIEW_MINOR_VERSION); - } - - public void testRecordPatternsPreview1ExhaustivenessOK1() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 - // TODO: Remove redundant default clauses when fixed upstream - System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); - runTest("record patterns exhaustiveness 1"); - } - - public void testRecordPatternsPreview1Aspect() { - runTest("record patterns aspect"); - } - - public void testRecordPatternsPreview1ExhaustivenessAspect() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 - // TODO: Remove redundant default clauses when fixed upstream - System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); - runTest("record patterns exhaustiveness aspect"); - } - - public void testRecordPatternsPreview1ExhaustivenessError() { - // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 - runTest("record patterns exhaustiveness error"); - } - - public void testRecordPatternsPreview1ExhaustivenessOK2() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 - // TODO: activate when fixed - System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); - //runTest("record patterns exhaustiveness 2"); + public void testDummyPreviewJava21() { + //runTest("dummy preview Java 21"); } public static Test suite() { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml index 1199bb03a..73f2bdf5b 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml @@ -1,19 +1,31 @@ - - - - + + + + @@ -28,28 +40,32 @@ + + + - + - + - - - - + + + + @@ -63,55 +79,58 @@ + + - + - + - + - - - + + + - + - + - + - + - + - + - + @@ -119,10 +138,10 @@ - + - - + + @@ -130,11 +149,11 @@ - + - + - + @@ -143,10 +162,10 @@ - + - - + + @@ -159,320 +178,21 @@ - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 3bca8528f33a3648f3646aeeb2f0b55576b0fc64 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 1 Nov 2023 08:50:17 +0700 Subject: [PATCH 15/29] Adjust to latest changes in JDT Core Signed-off-by: Alexander Kriegisch --- .../compiler/lookup/AjLookupEnvironment.java | 14 +++++++------- .../compiler/batch/messages_aspectj.properties | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index 6fc9de7dd..c187aa5bf 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -128,27 +128,27 @@ public void completeTypeBindings() { ContextToken completeTypeBindingsToken = enteringPhase(COMPLETING_TYPE_BINDINGS, ""); // builtInterTypesAndPerClauses = false; // pendingTypesToWeave = new ArrayList(); - stepCompleted = BUILD_TYPE_HIERARCHY; + stepCompleted = CompleteTypeBindingsSteps.CONNECT_TYPE_HIERARCHY; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = enteringPhase(CHECK_AND_SET_IMPORTS, units[i].compilationResult.fileName); units[i].scope.checkAndSetImports(); leavingPhase(tok); } - stepCompleted = CHECK_AND_SET_IMPORTS; + stepCompleted = CompleteTypeBindingsSteps.CHECK_AND_SET_IMPORTS; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = enteringPhase(CONNECTING_TYPE_HIERARCHY1, units[i].compilationResult.fileName); - units[i].scope.connectTypeHierarchy1(); + units[i].scope.connectTypeHierarchy(); leavingPhase(tok); } - stepCompleted = CONNECT_TYPE_HIERARCHY1; + stepCompleted = CompleteTypeBindingsSteps.CONNECT_TYPE_HIERARCHY; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = enteringPhase(CONNECTING_TYPE_HIERARCHY2, units[i].compilationResult.fileName); - units[i].scope.connectTypeHierarchy2(); + units[i].scope.integrateAnnotationsInHierarchy(); leavingPhase(tok); } - stepCompleted = CONNECT_TYPE_HIERARCHY2; + stepCompleted = CompleteTypeBindingsSteps.INTEGRATE_ANNOTATIONS_IN_HIERARCHY; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { ContextToken tok = enteringPhase(BUILDING_FIELDS_AND_METHODS, units[i].compilationResult.fileName); // units[i].scope.checkParameterizedTypes(); do this check a little later, after ITDs applied to stbs @@ -283,7 +283,7 @@ public void completeTypeBindings() { units[i] = null; // release unnecessary reference to the parsed unit } - stepCompleted = BUILD_FIELDS_AND_METHODS; + stepCompleted = CompleteTypeBindingsSteps.BUILD_FIELDS_AND_METHODS; lastCompletedUnitIndex = lastUnitIndex; AsmManager.setCompletingTypeBindings(false); factory.getWorld().getCrosscuttingMembersSet().verify(); diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties index d2b9afa41..02617606e 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler d23a141971a37b (27Apr2023) - Java20 +compiler.version = Eclipse Compiler 3e6295cd3e87e5 (29Oct2023) - Java21 compiler.copyright = misc.version = {0} {1} - {2} {3} From f0c0088286c17f8a5bf6fa8a00b01a7f46568cf4 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Wed, 1 Nov 2023 08:52:44 +0700 Subject: [PATCH 16/29] Switch CI build to Temurin JDK 21 final (from EA) Signed-off-by: Alexander Kriegisch --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e8ab9505a..44b0bec0f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: # Check for available Temurin releases on https://adoptium.net/releases.html - java: [ 17, 21-ea ] + java: [ 17, 21 ] runs-on: ubuntu-latest From 70f3c09bcdd80f682b098f22da8b6285211e46da Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 5 Nov 2023 10:03:23 +0700 Subject: [PATCH 17/29] Enable some tests after J19 problems were fixed for J21 Two test classes which had redundant default clauses for switch with record patterns were copied from the java19 to the java21 directory and the redundant clauses deactivated, i.e. the test now run as originally intended. For older JDK versions, the old tests still stay active in order to document the old state of affairs. Signed-off-by: Alexander Kriegisch --- ...ordPatternsPreview1ExhaustivenessAspect.aj | 6 ++-- ...cordPatternsPreview1ExhaustivenessOK1.java | 6 ++-- ...ordPatternsPreview1ExhaustivenessAspect.aj | 35 +++++++++++++++++++ .../systemtest/ajc1921/Ajc1921TestsJava.java | 20 ++++------- .../aspectj/systemtest/ajc1921/ajc1921.xml | 5 ++- 5 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 tests/features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj index 4fad25327..37c73788f 100644 --- a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj @@ -13,7 +13,8 @@ public aspect RecordPatternsPreview1ExhaustivenessAspect { switch (pair) { case Pair(I i, C c) -> System.out.println("x"); case Pair(I i, D d) -> System.out.println("y"); - // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed + // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. + // Fixed since Java 21, see features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj. default -> System.out.println("z"); } @@ -21,7 +22,8 @@ public aspect RecordPatternsPreview1ExhaustivenessAspect { case Pair(C c, I i) -> System.out.println("a"); case Pair(D d, C c) -> System.out.println("b"); case Pair(D d1, D d2) -> System.out.println("c"); - // TODO: remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed + // TODO: remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. + // Fixed since Java 21, see features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj. default -> System.out.println("d"); } } diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java index e815c512d..1d1d9d4f3 100644 --- a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java @@ -10,7 +10,8 @@ static void exhaustiveSwitch() { switch (p2) { case Pair(I i, C c) -> System.out.println("x"); case Pair(I i, D d) -> System.out.println("y"); - // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed + // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. + // Fixed since Java 21, see features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java. default -> System.out.println("z"); } @@ -18,7 +19,8 @@ static void exhaustiveSwitch() { case Pair(C c, I i) -> System.out.println("a"); case Pair(D d, C c) -> System.out.println("b"); case Pair(D d1, D d2) -> System.out.println("c"); - // TODO: remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed + // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. + // Fixed since Java 21, see features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java. default -> System.out.println("d"); } } diff --git a/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj new file mode 100644 index 000000000..d87c99ffd --- /dev/null +++ b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessAspect.aj @@ -0,0 +1,35 @@ +public aspect RecordPatternsPreview1ExhaustivenessAspect { + static Pair p2 = new Pair<>(new C(), new D()); + + public static void main(String[] args) { + doSomething(p2); + } + + public static void doSomething(Pair pair) { + System.out.println(pair.toString().replaceAll("@[0-9a-f]+", "@000")); + } + + before(Pair pair) : execution(* doSomething(Pair)) && args(pair) { + switch (pair) { + case Pair(I i, C c) -> System.out.println("x"); + case Pair(I i, D d) -> System.out.println("y"); + // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. + // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj. + // default -> System.out.println("z"); + } + + switch (pair) { + case Pair(C c, I i) -> System.out.println("a"); + case Pair(D d, C c) -> System.out.println("b"); + case Pair(D d1, D d2) -> System.out.println("c"); + // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. + // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj. + // default -> System.out.println("d"); + } + } +} + +sealed interface I permits C, D { } +final class C implements I { } +final class D implements I { } +record Pair(T x, T y) { } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java index 20efe1723..b0eaf3939 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java @@ -59,10 +59,8 @@ public void testRecordPatternsPreview1Error() { } public void testRecordPatternsPreview1ExhaustivenessOK1() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 - // TODO: Remove redundant default clauses when fixed upstream - System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21. runTest("record patterns exhaustiveness 1"); } @@ -71,10 +69,8 @@ public void testRecordPatternsPreview1Aspect() { } public void testRecordPatternsPreview1ExhaustivenessAspect() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 - // TODO: Remove redundant default clauses when fixed upstream - System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. Fixed in Java 21. runTest("record patterns exhaustiveness aspect"); } @@ -84,11 +80,9 @@ public void testRecordPatternsPreview1ExhaustivenessError() { } public void testRecordPatternsPreview1ExhaustivenessOK2() { - // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', - // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 - // TODO: activate when fixed - System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); - //runTest("record patterns exhaustiveness 2"); + // Used to falsely throw 'An enhanced switch statement should be exhaustive; a default label expected', + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398. Fixed in Java 21. + runTest("record patterns exhaustiveness 2"); } public static Test suite() { diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml index 73f2bdf5b..ec4682216 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml @@ -139,7 +139,7 @@ - + @@ -150,9 +150,8 @@ - + - From 05de091a064ffc7e34f288ee5542900f47e982de Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 19 Nov 2023 13:22:14 +0700 Subject: [PATCH 18/29] Release milestone 1.9.21.M1 Signed-off-by: Alexander Kriegisch --- ajde.core/pom.xml | 2 +- ajde/pom.xml | 2 +- ajdoc/pom.xml | 2 +- asm/pom.xml | 2 +- aspectjmatcher/pom.xml | 2 +- aspectjrt/pom.xml | 2 +- aspectjtools/pom.xml | 2 +- aspectjweaver/pom.xml | 2 +- bcel-builder/pom.xml | 2 +- bridge/pom.xml | 2 +- build/pom.xml | 2 +- docs/pom.xml | 2 +- installer/pom.xml | 2 +- lib/pom.xml | 2 +- loadtime/pom.xml | 2 +- org.aspectj.ajdt.core/pom.xml | 2 +- org.aspectj.matcher/pom.xml | 2 +- pom.xml | 2 +- run-all-junit-tests/pom.xml | 2 +- runtime/pom.xml | 2 +- taskdefs/pom.xml | 2 +- testing-client/pom.xml | 2 +- testing-drivers/pom.xml | 2 +- testing-util/pom.xml | 2 +- testing/pom.xml | 2 +- tests/pom.xml | 2 +- util/pom.xml | 2 +- weaver/pom.xml | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ajde.core/pom.xml b/ajde.core/pom.xml index ef754cc6e..f1031b2f2 100644 --- a/ajde.core/pom.xml +++ b/ajde.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 ajde.core diff --git a/ajde/pom.xml b/ajde/pom.xml index 8f37275f2..cd4309d06 100644 --- a/ajde/pom.xml +++ b/ajde/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 ajde diff --git a/ajdoc/pom.xml b/ajdoc/pom.xml index b0f8c8e80..8e9608f57 100644 --- a/ajdoc/pom.xml +++ b/ajdoc/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 ajdoc diff --git a/asm/pom.xml b/asm/pom.xml index 9808a4c9c..e961194e3 100644 --- a/asm/pom.xml +++ b/asm/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 asm diff --git a/aspectjmatcher/pom.xml b/aspectjmatcher/pom.xml index b26e3c0ba..43699b63f 100644 --- a/aspectjmatcher/pom.xml +++ b/aspectjmatcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 aspectjmatcher diff --git a/aspectjrt/pom.xml b/aspectjrt/pom.xml index b18defa4c..fe0262f73 100644 --- a/aspectjrt/pom.xml +++ b/aspectjrt/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 aspectjrt diff --git a/aspectjtools/pom.xml b/aspectjtools/pom.xml index d637f1e76..381ca85d1 100644 --- a/aspectjtools/pom.xml +++ b/aspectjtools/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 aspectjtools diff --git a/aspectjweaver/pom.xml b/aspectjweaver/pom.xml index 9c8ef1dce..e6dbf10b4 100644 --- a/aspectjweaver/pom.xml +++ b/aspectjweaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 aspectjweaver diff --git a/bcel-builder/pom.xml b/bcel-builder/pom.xml index 9ca24dcd8..5653ac424 100644 --- a/bcel-builder/pom.xml +++ b/bcel-builder/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 bcel-builder diff --git a/bridge/pom.xml b/bridge/pom.xml index 184f11014..94fccc49f 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 bridge diff --git a/build/pom.xml b/build/pom.xml index 19dec9afb..d94f2e8a9 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 build diff --git a/docs/pom.xml b/docs/pom.xml index 7c33da969..240ef0880 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 docs diff --git a/installer/pom.xml b/installer/pom.xml index 15ad3b4a8..788ef9255 100644 --- a/installer/pom.xml +++ b/installer/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 installer diff --git a/lib/pom.xml b/lib/pom.xml index ee0c9ee0d..cf0912f5b 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -7,7 +7,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 lib diff --git a/loadtime/pom.xml b/loadtime/pom.xml index fb571516f..606fb8c65 100644 --- a/loadtime/pom.xml +++ b/loadtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 loadtime diff --git a/org.aspectj.ajdt.core/pom.xml b/org.aspectj.ajdt.core/pom.xml index 71c86d25f..a35ba96b1 100644 --- a/org.aspectj.ajdt.core/pom.xml +++ b/org.aspectj.ajdt.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 org.aspectj.ajdt.core diff --git a/org.aspectj.matcher/pom.xml b/org.aspectj.matcher/pom.xml index 70937bef3..36ac7eb4b 100644 --- a/org.aspectj.matcher/pom.xml +++ b/org.aspectj.matcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 org.aspectj.matcher diff --git a/pom.xml b/pom.xml index 1ea0bc1bd..555bfe7cb 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 pom AspectJ Parent Project diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml index b960cb0ff..756875cc0 100644 --- a/run-all-junit-tests/pom.xml +++ b/run-all-junit-tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 run-all-junit-tests diff --git a/runtime/pom.xml b/runtime/pom.xml index d38fba016..e02f5cdff 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 runtime diff --git a/taskdefs/pom.xml b/taskdefs/pom.xml index 67d68fa92..6b8a7fe5f 100644 --- a/taskdefs/pom.xml +++ b/taskdefs/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 taskdefs diff --git a/testing-client/pom.xml b/testing-client/pom.xml index 74aee012b..c9f16a83b 100644 --- a/testing-client/pom.xml +++ b/testing-client/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 testing-client diff --git a/testing-drivers/pom.xml b/testing-drivers/pom.xml index 720257659..d70847258 100644 --- a/testing-drivers/pom.xml +++ b/testing-drivers/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 testing-drivers diff --git a/testing-util/pom.xml b/testing-util/pom.xml index 8ecf6cce9..45146f886 100644 --- a/testing-util/pom.xml +++ b/testing-util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 testing-util diff --git a/testing/pom.xml b/testing/pom.xml index 84d328fd6..96d96ddf1 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 testing diff --git a/tests/pom.xml b/tests/pom.xml index eb6eb421d..fc02cc7d4 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 tests diff --git a/util/pom.xml b/util/pom.xml index 0871f8d32..8117665f1 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 util diff --git a/weaver/pom.xml b/weaver/pom.xml index 8fcf6f279..98a08ef2a 100644 --- a/weaver/pom.xml +++ b/weaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21-SNAPSHOT + 1.9.21.M1 weaver From 8e8d81cae8b098f3289253aeda20e77a43939866 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 19 Nov 2023 13:26:39 +0700 Subject: [PATCH 19/29] Set version 1.9.21-SNAPSHOT Signed-off-by: Alexander Kriegisch --- ajde.core/pom.xml | 2 +- ajde/pom.xml | 2 +- ajdoc/pom.xml | 2 +- asm/pom.xml | 2 +- aspectjmatcher/pom.xml | 2 +- aspectjrt/pom.xml | 2 +- aspectjtools/pom.xml | 2 +- aspectjweaver/pom.xml | 2 +- bcel-builder/pom.xml | 2 +- bridge/pom.xml | 2 +- build/pom.xml | 2 +- docs/pom.xml | 2 +- installer/pom.xml | 2 +- lib/pom.xml | 2 +- loadtime/pom.xml | 2 +- org.aspectj.ajdt.core/pom.xml | 2 +- org.aspectj.matcher/pom.xml | 2 +- pom.xml | 2 +- run-all-junit-tests/pom.xml | 2 +- runtime/pom.xml | 2 +- taskdefs/pom.xml | 2 +- testing-client/pom.xml | 2 +- testing-drivers/pom.xml | 2 +- testing-util/pom.xml | 2 +- testing/pom.xml | 2 +- tests/pom.xml | 2 +- util/pom.xml | 2 +- weaver/pom.xml | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ajde.core/pom.xml b/ajde.core/pom.xml index f1031b2f2..ef754cc6e 100644 --- a/ajde.core/pom.xml +++ b/ajde.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT ajde.core diff --git a/ajde/pom.xml b/ajde/pom.xml index cd4309d06..8f37275f2 100644 --- a/ajde/pom.xml +++ b/ajde/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT ajde diff --git a/ajdoc/pom.xml b/ajdoc/pom.xml index 8e9608f57..b0f8c8e80 100644 --- a/ajdoc/pom.xml +++ b/ajdoc/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT ajdoc diff --git a/asm/pom.xml b/asm/pom.xml index e961194e3..9808a4c9c 100644 --- a/asm/pom.xml +++ b/asm/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT asm diff --git a/aspectjmatcher/pom.xml b/aspectjmatcher/pom.xml index 43699b63f..b26e3c0ba 100644 --- a/aspectjmatcher/pom.xml +++ b/aspectjmatcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT aspectjmatcher diff --git a/aspectjrt/pom.xml b/aspectjrt/pom.xml index fe0262f73..b18defa4c 100644 --- a/aspectjrt/pom.xml +++ b/aspectjrt/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT aspectjrt diff --git a/aspectjtools/pom.xml b/aspectjtools/pom.xml index 381ca85d1..d637f1e76 100644 --- a/aspectjtools/pom.xml +++ b/aspectjtools/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT aspectjtools diff --git a/aspectjweaver/pom.xml b/aspectjweaver/pom.xml index e6dbf10b4..9c8ef1dce 100644 --- a/aspectjweaver/pom.xml +++ b/aspectjweaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT aspectjweaver diff --git a/bcel-builder/pom.xml b/bcel-builder/pom.xml index 5653ac424..9ca24dcd8 100644 --- a/bcel-builder/pom.xml +++ b/bcel-builder/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT bcel-builder diff --git a/bridge/pom.xml b/bridge/pom.xml index 94fccc49f..184f11014 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT bridge diff --git a/build/pom.xml b/build/pom.xml index d94f2e8a9..19dec9afb 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT build diff --git a/docs/pom.xml b/docs/pom.xml index 240ef0880..7c33da969 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT docs diff --git a/installer/pom.xml b/installer/pom.xml index 788ef9255..15ad3b4a8 100644 --- a/installer/pom.xml +++ b/installer/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT installer diff --git a/lib/pom.xml b/lib/pom.xml index cf0912f5b..ee0c9ee0d 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -7,7 +7,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT lib diff --git a/loadtime/pom.xml b/loadtime/pom.xml index 606fb8c65..fb571516f 100644 --- a/loadtime/pom.xml +++ b/loadtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT loadtime diff --git a/org.aspectj.ajdt.core/pom.xml b/org.aspectj.ajdt.core/pom.xml index a35ba96b1..71c86d25f 100644 --- a/org.aspectj.ajdt.core/pom.xml +++ b/org.aspectj.ajdt.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT org.aspectj.ajdt.core diff --git a/org.aspectj.matcher/pom.xml b/org.aspectj.matcher/pom.xml index 36ac7eb4b..70937bef3 100644 --- a/org.aspectj.matcher/pom.xml +++ b/org.aspectj.matcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT org.aspectj.matcher diff --git a/pom.xml b/pom.xml index 555bfe7cb..1ea0bc1bd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT pom AspectJ Parent Project diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml index 756875cc0..b960cb0ff 100644 --- a/run-all-junit-tests/pom.xml +++ b/run-all-junit-tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT run-all-junit-tests diff --git a/runtime/pom.xml b/runtime/pom.xml index e02f5cdff..d38fba016 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT runtime diff --git a/taskdefs/pom.xml b/taskdefs/pom.xml index 6b8a7fe5f..67d68fa92 100644 --- a/taskdefs/pom.xml +++ b/taskdefs/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT taskdefs diff --git a/testing-client/pom.xml b/testing-client/pom.xml index c9f16a83b..74aee012b 100644 --- a/testing-client/pom.xml +++ b/testing-client/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT testing-client diff --git a/testing-drivers/pom.xml b/testing-drivers/pom.xml index d70847258..720257659 100644 --- a/testing-drivers/pom.xml +++ b/testing-drivers/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT testing-drivers diff --git a/testing-util/pom.xml b/testing-util/pom.xml index 45146f886..8ecf6cce9 100644 --- a/testing-util/pom.xml +++ b/testing-util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT testing-util diff --git a/testing/pom.xml b/testing/pom.xml index 96d96ddf1..84d328fd6 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT testing diff --git a/tests/pom.xml b/tests/pom.xml index fc02cc7d4..eb6eb421d 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT tests diff --git a/util/pom.xml b/util/pom.xml index 8117665f1..0871f8d32 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT util diff --git a/weaver/pom.xml b/weaver/pom.xml index 98a08ef2a..8fcf6f279 100644 --- a/weaver/pom.xml +++ b/weaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.21.M1 + 1.9.21-SNAPSHOT weaver From 021fcf16f1828e311621d172dfb084fe309144f4 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 19 Nov 2023 13:48:26 +0700 Subject: [PATCH 20/29] RELEASE.md: Add '--add-opens' info for Nexus Staging 'rc:release' Sonatype has not solved the problems in Nexus Staging Maven Plugin for years, so it makes sense to document them. Signed-off-by: Alexander Kriegisch --- docs/developer/RELEASE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/developer/RELEASE.md b/docs/developer/RELEASE.md index 7feea0641..1a758a15f 100644 --- a/docs/developer/RELEASE.md +++ b/docs/developer/RELEASE.md @@ -159,6 +159,10 @@ mvn nexus-staging:rc-list # [INFO] ID State Description # [INFO] orgaspectj-1106 CLOSED org.aspectj:aspectjrt:1.9.8.M2 +# Because of problems in Nexus Staging Maven Plugin with more recent JDKs, +# we might need this first +export MAVEN_OPTS="--add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED" + # Use the ID of the corresponding CLOSED staging repository for releasing to # Maven Central mvn nexus-staging:rc-release -DstagingRepositoryId=orgaspectj-1106 From 9e09610f1ab49361c68c7d3d6f40ad71fb267f79 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 21 Nov 2023 07:48:37 +0700 Subject: [PATCH 21/29] AjcTaskTest: unwrap redundant if statement Signed-off-by: Alexander Kriegisch --- .../test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index 0281d66d4..eefb37ad6 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java @@ -1028,9 +1028,7 @@ private void check( holder, kind + " expected " + num + " got " + actual); } - if (num != actual){ - System.out.println("===\n"+Arrays.toString(holder.getMessages(kind, false))+"\n===\n"); - } + System.out.println("===\n" + Arrays.toString(holder.getMessages(kind, false)) + "\n===\n"); assertEquals(kind.toString(), num, actual); } } From 37f3f6c11135d0d6cac6ec2511f8d2baefdc8457 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 21 Nov 2023 07:51:58 +0700 Subject: [PATCH 22/29] AjcTaskTest: Be more lenient with aspectjrt version warning Filter out a warning which occurs, if the current release does not match the stored binary in lib/test: bad version number found in aspectjrt.jar expected 1.9.21.M1 found 1.9.20.1 If e.g. we run tests for a milestone release a.b.5.M1 and afterwards switch back to a.b.5-SNAPSHOT, we do not want to update lib/test for a single commit, just to make this test pass. Hence, we ignore this warning here. Signed-off-by: Alexander Kriegisch --- .../org/aspectj/tools/ant/taskdefs/AjcTaskTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index eefb37ad6..ae67012b9 100644 --- a/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java +++ b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java @@ -1021,6 +1021,18 @@ private void check( IMessage.Kind kind) { if (num != IGNORE) { int actual = holder.numMessages(kind, false); + + // Filter out a warning which occurs, if the current release does not match the stored binary in lib/test. + // If e.g. we run tests for a milestone release a.b.5.M1 and afterwards switch back to a.b.5-SNAPSHOT, we do not + // want to update lib/test for a single commit, just to make this test pass. Hence, we ignore this warning here. + if (kind.equals(IMessage.WARNING)) { + for (IMessage message : holder.getMessages(kind, false)) { + String warningMessage = message.getMessage(); + if (warningMessage.matches("bad version number found in .*aspectjrt.jar expected .* found .*")) + actual--; + } + } + if (num != actual) { if (actual > 0) { MessageUtil.print( From 93511aeb022abcf550124f7e7eb4ed5f7d917cd2 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 27 Nov 2023 11:14:04 +0700 Subject: [PATCH 23/29] Add missing file RecordPatternsPreview1ExhaustivenessOK1.java for JDK 21 This file was missing, which did not trigger an error in CI builds, because AllTestsAspectJ1921 was not part of the AllTests19 suite before. The latter will be fixed in the next commit. Signed-off-by: Alexander Kriegisch --- ...cordPatternsPreview1ExhaustivenessOK1.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java diff --git a/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java new file mode 100644 index 000000000..5be25f80a --- /dev/null +++ b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java @@ -0,0 +1,34 @@ +public class RecordPatternsPreview1ExhaustivenessOK1 { + static Pair p1 = new Pair<>(new A(), new B()); + static Pair p2 = new Pair<>(new C(), new D()); + + public static void main(String[] args) { + exhaustiveSwitch(); + } + + static void exhaustiveSwitch() { + switch (p2) { + case Pair(I i, C c) -> System.out.println("x"); + case Pair(I i, D d) -> System.out.println("y"); + // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. + // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java. + // default -> System.out.println("z"); + } + + switch (p2) { + case Pair(C c, I i) -> System.out.println("a"); + case Pair(D d, C c) -> System.out.println("b"); + case Pair(D d1, D d2) -> System.out.println("c"); + // Redundant default clause no longer necessary after fix of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455. + // Old version with default clause see features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java. + // default -> System.out.println("d"); + } + } +} + +class A { } +class B extends A { } +sealed interface I permits C, D { } +final class C implements I { } +final class D implements I { } +record Pair(T x, T y) { } From 6f2702e535185cdfabdc3f61f3d864954277d89d Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 27 Nov 2023 11:15:40 +0700 Subject: [PATCH 24/29] AllTests19 suite: add AllTestsAspectJ1921 Until now, the CI build did not run Java 21 tests, but they look OK locally. Now, let's find out what GitHub Actions says. Signed-off-by: Alexander Kriegisch --- tests/src/test/java/org/aspectj/systemtest/AllTests19.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java index 733102fba..dee55718c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java @@ -12,6 +12,7 @@ import org.aspectj.systemtest.ajc1919.AllTestsAspectJ1919; import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; import org.aspectj.systemtest.ajc1920.AllTestsAspectJ1920; +import org.aspectj.systemtest.ajc1921.AllTestsAspectJ1921; import org.aspectj.systemtest.ajc193.AllTestsAspectJ193; import org.aspectj.systemtest.ajc195.AllTestsAspectJ195; import org.aspectj.systemtest.ajc196.AllTestsAspectJ196; @@ -42,6 +43,7 @@ public static Test suite() { suite.addTest(AllTestsAspectJ199.suite()); suite.addTest(AllTestsAspectJ1919.suite()); suite.addTest(AllTestsAspectJ1920.suite()); + suite.addTest(AllTestsAspectJ1921.suite()); suite.addTest(AllTests18.suite()); // $JUnit-END$ return suite; From 4714dea05beb8f5b5ebba6277baa1ca440281d46 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 27 Nov 2023 11:17:27 +0700 Subject: [PATCH 25/29] Reactivate some tests on JDK 21 after upstream fix https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 has finally been fixed. Signed-off-by: Alexander Kriegisch --- .../java21/SwitchPatternPreview3Aspect.aj | 9 --------- .../features1921/java21/SwitchPatternPreview4OK.java | 12 ------------ .../org/aspectj/systemtest/ajc1921/ajc1921.xml | 8 +------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/tests/features1921/java21/SwitchPatternPreview3Aspect.aj b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj index cab9a2bcd..ae147dad7 100644 --- a/tests/features1921/java21/SwitchPatternPreview3Aspect.aj +++ b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj @@ -31,14 +31,6 @@ aspect SwitchPatternPreview3Aspect { } Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { - // This used to work in preview 4 (Java 20), but fails during runtime with - // java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 - // in ECJ 3.36.0-SNAPSHOT with Java 21. - // See: - // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. - // - // TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. - /* System.out.println( switch (i) { case null -> "value unavailable: " + i; @@ -47,7 +39,6 @@ aspect SwitchPatternPreview3Aspect { default -> "other integer: " + i; } ); - */ return proceed(i); } } diff --git a/tests/features1921/java21/SwitchPatternPreview4OK.java b/tests/features1921/java21/SwitchPatternPreview4OK.java index c9caf7eca..40854a007 100644 --- a/tests/features1921/java21/SwitchPatternPreview4OK.java +++ b/tests/features1921/java21/SwitchPatternPreview4OK.java @@ -29,15 +29,12 @@ public static void main(String[] args) { // constantLabelMustAppearBeforePattern(Integer.valueOf(123)); // constantLabelMustAppearBeforePattern(null); - // TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. - /* constantLabelMustAppearBeforePatternInteger(-1); constantLabelMustAppearBeforePatternInteger(0); constantLabelMustAppearBeforePatternInteger(42); constantLabelMustAppearBeforePatternInteger(-99); constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); constantLabelMustAppearBeforePatternInteger(null); - */ System.out.println(testGenericSealedExhaustive(new E())); } @@ -105,15 +102,6 @@ static String constantLabelMustAppearBeforePattern(Object o) { } */ - /** - * This used to work in preview 4 (Java 20), but fails during runtime with - * java.lang.IndexOutOfBoundsException: Index 4 out of bounds for length 4 - * in ECJ 3.36.0-SNAPSHOT with Java 21. - * See: - * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466. - * - * TODO: Activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1466 is fixed. - */ static String constantLabelMustAppearBeforePatternInteger(Integer i) { switch (i) { case null -> System.out.println("value unavailable: " + i); diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml index ec4682216..42a58da0c 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml @@ -26,7 +26,7 @@ - + @@ -40,15 +40,12 @@ - - @@ -79,15 +76,12 @@ - - From e761f6132299702b6b19efe09e1e09530d4a64e8 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 27 Nov 2023 11:20:30 +0700 Subject: [PATCH 26/29] Bump AJC version string to c13b03ceabf0c1 More exactly: Eclipse Compiler c13b03ceabf0c1 (26Nov2023) - Java21 Signed-off-by: Alexander Kriegisch --- .../jdt/internal/compiler/batch/messages_aspectj.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties index 02617606e..4df93191a 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler 3e6295cd3e87e5 (29Oct2023) - Java21 +compiler.version = Eclipse Compiler c13b03ceabf0c1 (26Nov2023) - Java21 compiler.copyright = misc.version = {0} {1} - {2} {3} From 853208768355097f98ab9531aa1314c63a0e04a1 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Fri, 1 Dec 2023 20:13:12 +0700 Subject: [PATCH 27/29] Adjust to API changes in ECJ 4dc7b558 (01Dec2023) Mostly StringBuffer -> StringBuilder API changes Signed-off-by: Alexander Kriegisch --- .../ajdt/internal/compiler/ast/AdviceDeclaration.java | 6 +++--- .../ajdt/internal/compiler/ast/AspectDeclaration.java | 2 +- .../ajdt/internal/compiler/ast/DeclareDeclaration.java | 2 +- .../ajdt/internal/compiler/ast/PointcutDesignator.java | 4 ++-- .../ajdt/internal/compiler/ast/PseudoToken.java | 4 ++-- .../ajdt/internal/compiler/ast/PseudoTokens.java | 4 ++-- .../internal/core/builder/AsmHierarchyBuilder.java | 10 +++++----- .../compiler/batch/messages_aspectj.properties | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index 4579308b9..8d10b3676 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -331,7 +331,7 @@ public void postParse(TypeDeclaration typeDec) { AspectDeclaration aspectDecl = (AspectDeclaration) typeDec; adviceSequenceNumberInType = aspectDecl.adviceCounter++; - StringBuffer stringifiedPointcut = new StringBuffer(30); + StringBuilder stringifiedPointcut = new StringBuilder(30); pointcutDesignator.print(0, stringifiedPointcut); this.selector = NameMangler.adviceName(EclipseFactory.getName(typeDec.binding).replace('.', '_'), kind, adviceSequenceNumberInType, stringifiedPointcut.toString().hashCode()).toCharArray(); @@ -459,7 +459,7 @@ private static Argument[] extendArgumentsLength(Argument[] args, int addedArgume // return s; // } - public StringBuffer printBody(int indent, StringBuffer output) { + public StringBuilder printBody(int indent, StringBuilder output) { output.append(": "); if (pointcutDesignator != null) { output.append(pointcutDesignator.toString()); @@ -467,7 +467,7 @@ public StringBuffer printBody(int indent, StringBuffer output) { return super.printBody(indent, output); } - public StringBuffer printReturnType(int indent, StringBuffer output) { + public StringBuilder printReturnType(int indent, StringBuilder output) { if (this.kind == AdviceKind.Around) { return super.printReturnType(indent, output); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index a1e7d5cdf..0daa12747 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -1289,7 +1289,7 @@ private IntertypeMemberTypeFinder findOrCreateInterTypeMemberClassFinder(SourceT return finder; } - public StringBuffer printHeader(int indent, StringBuffer output) { + public StringBuilder printHeader(int indent, StringBuilder output) { // since all aspects are made public we want to print the // modifiers that were supplied in the original source code printModifiers(this.declaredModifiers, output); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java index b085a0362..99a8a8dd0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java @@ -153,7 +153,7 @@ public Declare build(ClassScope classScope) { return declareDecl; } - public StringBuffer print(int tab, StringBuffer output) { + public StringBuilder print(int tab, StringBuilder output) { printIndent(tab, output); if (declareDecl == null) { output.append(""); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDesignator.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDesignator.java index 65bc72bd9..006e54a2b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDesignator.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PointcutDesignator.java @@ -113,9 +113,9 @@ public boolean isError() { /* * (non-Javadoc) * - * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer) + * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuilder) */ - public StringBuffer print(int indent, StringBuffer output) { + public StringBuilder print(int indent, StringBuilder output) { if (pointcut == null) return output.append(""); return output.append(pointcut.toString()); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoToken.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoToken.java index 3b3a61bd8..9c97d1c12 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoToken.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoToken.java @@ -86,9 +86,9 @@ public int postParse(TypeDeclaration typeDec, MethodDeclaration enclosingDec, in } /* (non-Javadoc) - * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer) + * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuilder) */ - public StringBuffer print(int indent, StringBuffer output) { + public StringBuilder print(int indent, StringBuilder output) { output.append("PseudoToken<" + getString() + ">"); return output; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java index 5cd976441..a9cf41801 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/PseudoTokens.java @@ -159,9 +159,9 @@ public void postParse(TypeDeclaration typeDec, MethodDeclaration enclosingDec) { } /* (non-Javadoc) - * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuffer) + * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#print(int, java.lang.StringBuilder) */ - public StringBuffer print(int indent, StringBuffer output) { + public StringBuilder print(int indent, StringBuilder output) { output.append(tokenSource.toString()); return output; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index 9410f1806..2d61403c0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -497,7 +497,7 @@ public void endVisit(TypeDeclaration memberTypeDeclaration, BlockScope scope) { } private String genSourceSignature(TypeDeclaration typeDeclaration) { - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(); typeDeclaration.printHeader(0, output); return output.toString(); } @@ -689,7 +689,7 @@ private void addAllNamed(Pointcut pointcut, List pointcuts) { } private String genSourceSignature(MethodDeclaration methodDeclaration) { - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(); ASTNode.printModifiers(methodDeclaration.modifiers, output); // Append Type Parameters if any @@ -815,7 +815,7 @@ public void endVisit(ImportReference importRef, CompilationUnitScope scope) { } private String genSourceSignature(ImportReference importreference) { - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(); output.append("import "); ASTNode.printModifiers(importreference.modifiers, output); output.append(importreference); @@ -939,7 +939,7 @@ protected String generateJavadocComment(ASTNode astNode) { * */ protected String genSourceSignature(FieldDeclaration fieldDeclaration) { - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(); if (fieldDeclaration.type == null) { // This is an enum value output.append(fieldDeclaration.name); // the "," or ";" has to be // put on by whatever uses @@ -1032,7 +1032,7 @@ public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope s } private String genSourceSignature(ConstructorDeclaration constructorDeclaration) { - StringBuffer output = new StringBuffer(); + StringBuilder output = new StringBuilder(); ASTNode.printModifiers(constructorDeclaration.modifiers, output); // Append Type Parameters if any diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties index 4df93191a..a6b92abde 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler c13b03ceabf0c1 (26Nov2023) - Java21 +compiler.version = Eclipse Compiler 4dc7b558f82274 (01Dec2023) - Java21 compiler.copyright = misc.version = {0} {1} - {2} {3} From 00b87d75dff48ea56d69edd2826d20c1bc307af6 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sat, 2 Dec 2023 07:28:16 +0700 Subject: [PATCH 28/29] Bump ECJ to 23b713ce (01Dec2023) Signed-off-by: Alexander Kriegisch --- .../jdt/internal/compiler/batch/messages_aspectj.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties index a6b92abde..4ae767768 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler 4dc7b558f82274 (01Dec2023) - Java21 +compiler.version = Eclipse Compiler 23b713ce21cc8c (01Dec2023) - Java21 compiler.copyright = misc.version = {0} {1} - {2} {3} From dfd6e38768ceb4450e9a08b5c9c488d4c0e2c6fb Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sat, 2 Dec 2023 08:56:20 +0700 Subject: [PATCH 29/29] Bump JDT Core to 1.9.21.RC1 Signed-off-by: Alexander Kriegisch --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1ea0bc1bd..84f24150f 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ true - 1.9.21-SNAPSHOT + 1.9.21.RC1 9.6 1.6.3 2.6.2