diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index cd1d223d45..44b0bec0f4 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: [ 17, 21 ] runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index d0b7450be4..a55fb96016 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 diff --git a/ajde.core/testdata/BuildCancelling/.cvsignore b/ajde.core/testdata/BuildCancelling/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- 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 17637b4558..0000000000 --- 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 c6495af698..0000000000 --- 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 9a2b438e38..0000000000 --- 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 d9011a8881..0000000000 --- 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 1dd78c3c0b..0000000000 --- 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 fd0572c5e7..0000000000 --- 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 ff5587df80..0000000000 --- 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 3be9773da1..0000000000 --- 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 0029faaf6b..0000000000 --- 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 7d07f70315..0000000000 --- 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 14314ab36c..0000000000 --- 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 ba077a4031..0000000000 --- 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 5e8d7b6188..0000000000 --- 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 ba077a4031..0000000000 --- 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 bd4e1a00bc..0000000000 --- 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 17637b4558..0000000000 --- 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 17637b4558..0000000000 --- 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 c6495af698..0000000000 --- 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 9a2b438e38..0000000000 --- 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 d9011a8881..0000000000 --- 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 1dd78c3c0b..0000000000 --- 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 fd0572c5e7..0000000000 --- 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 ad69a1aa9d..0000000000 --- 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 ba077a4031..0000000000 --- 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 17637b4558..0000000000 --- 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 c6495af698..0000000000 --- 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 9a2b438e38..0000000000 --- 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 d9011a8881..0000000000 --- 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 1dd78c3c0b..0000000000 --- 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 fd0572c5e7..0000000000 --- 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 a5f90a68ec..0000000000 --- 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 8e695ec83a..0000000000 --- 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 8e695ec83a..0000000000 --- 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 8e695ec83a..0000000000 --- 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 ad69a1aa9d..0000000000 --- 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 8e695ec83a..0000000000 --- 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 e9f81f44ba..0000000000 --- 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 17637b4558..0000000000 --- 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 edd86b3564..0000000000 --- a/asm/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -asm.lst -asmSrc.lst 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 216bdfdde8..77477747c7 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/bridge/src/.cvsignore b/bridge/src/.cvsignore deleted file mode 100644 index a3f0b1b779..0000000000 --- a/bridge/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst 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 bfb8ec190c..451c9cca71 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/docs/developer/RELEASE.md b/docs/developer/RELEASE.md index 7feea06417..1a758a15fa 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 diff --git a/docs/sandbox/aopalliance/.cvsignore b/docs/sandbox/aopalliance/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- 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 d6be13d967..0000000000 --- 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 a3f0b1b779..0000000000 --- a/org.aspectj.ajdt.core/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst 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 4579308b95..8d10b36762 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 a1e7d5cdf5..0daa127470 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 b085a0362e..99a8a8dd0d 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 65bc72bd9a..006e54a2ba 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 3b3a61bd8b..9c97d1c121 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 5cd9764414..a9cf418011 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/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index e0123ee4ac..c187aa5bf5 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,39 +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; + stepCompleted = CompleteTypeBindingsSteps.CONNECT_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; + stepCompleted = CompleteTypeBindingsSteps.CHECK_AND_SET_IMPORTS; for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY, - units[i].compilationResult.fileName); + ContextToken tok = enteringPhase(CONNECTING_TYPE_HIERARCHY1, units[i].compilationResult.fileName); units[i].scope.connectTypeHierarchy(); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } - stepCompleted = CONNECT_TYPE_HIERARCHY; - + 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.integrateAnnotationsInHierarchy(); + leavingPhase(tok); + } + stepCompleted = CompleteTypeBindingsSteps.INTEGRATE_ANNOTATIONS_IN_HIERARCHY; 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) { @@ -176,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++) { @@ -204,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); } @@ -219,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++) { @@ -251,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 { @@ -277,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); } } @@ -298,63 +283,57 @@ 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(); - 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); @@ -370,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 @@ -388,7 +366,7 @@ private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection< buildInterTypeAndPerClause(sourceType.scope); addCrosscuttingStructures(sourceType.scope); - CompilationAndWeavingContext.leavingPhase(tok); + leavingPhase(tok); } /** @@ -400,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(); @@ -417,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(); } @@ -544,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); } } @@ -589,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]); } } } @@ -600,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); } @@ -611,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); } } @@ -665,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); @@ -680,26 +677,18 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List entry : dangerousInterfaces.entrySet()) { ResolvedType interfaceType = entry.getKey(); if (onType.isTopmostImplementor(interfaceType)) { @@ -712,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); @@ -759,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(); @@ -825,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) { @@ -870,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()); } } } @@ -879,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()) { @@ -888,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; } @@ -944,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()) { @@ -964,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(); @@ -978,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; @@ -1000,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(); @@ -1045,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) @@ -1063,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; } @@ -1075,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; } } @@ -1129,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( @@ -1176,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; } @@ -1203,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; } @@ -1288,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()) { @@ -1353,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; @@ -1374,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; @@ -1407,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); } } @@ -1419,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); @@ -1439,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); @@ -1463,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"); + } + } + } + } +*/ + +} 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 9410f1806b..2d61403c02 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 d2b9afa41d..4ae767768d 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 23b713ce21cc8c (01Dec2023) - Java21 compiler.copyright = misc.version = {0} {1} - {2} {3} 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 e50ea97575..9aec7d947d 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); diff --git a/org.aspectj.ajdt.core/testdata/src1/.cvsignore b/org.aspectj.ajdt.core/testdata/src1/.cvsignore deleted file mode 100644 index c06bd3c77b..0000000000 --- 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 6b468b62a9..0000000000 --- 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 defacf0999..0000000000 --- a/org.aspectj.matcher/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bcweaver.lst -bcweaverSrc.lst diff --git a/pom.xml b/pom.xml index 8a9557dadf..84f24150fd 100644 --- a/pom.xml +++ b/pom.xml @@ -21,8 +21,8 @@ true - 1.9.20 - 9.5 + 1.9.21.RC1 + 9.6 1.6.3 2.6.2 1.2 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 23905d45dd..ab99fd670f 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/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java b/taskdefs/src/test/java/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java index 0281d66d42..ae67012b9c 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( @@ -1028,9 +1040,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); } } diff --git a/testing-client/src/.cvsignore b/testing-client/src/.cvsignore deleted file mode 100644 index a3f0b1b779..0000000000 --- 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 a3f0b1b779..0000000000 --- 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 a3f0b1b779..0000000000 --- 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 c6495af698..0000000000 --- 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 9a2b438e38..0000000000 --- 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 d9011a8881..0000000000 --- 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 1dd78c3c0b..0000000000 --- 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 fd0572c5e7..0000000000 --- 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 a3f0b1b779..0000000000 --- a/testing/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/testing/src/test/java/org/aspectj/testing/AntSpec.java b/testing/src/test/java/org/aspectj/testing/AntSpec.java index 9d239d61bf..07f2f10ff0 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); } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava20Only.java index aeb1152fd7..4e0567d0df 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 0000000000..fb6795b3da --- /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 0000000000..4c1d59d15a --- /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/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/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj index 4fad253271..37c73788fc 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 e815c512df..1d1d9d4f38 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 0000000000..d87c99ffdf --- /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/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1921/java21/RecordPatternsPreview1ExhaustivenessOK1.java new file mode 100644 index 0000000000..5be25f80ac --- /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) { } diff --git a/tests/features1921/java21/SwitchPatternPreview3Aspect.aj b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj new file mode 100644 index 0000000000..ae147dad7c --- /dev/null +++ b/tests/features1921/java21/SwitchPatternPreview3Aspect.aj @@ -0,0 +1,88 @@ +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) { + 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 0000000000..40854a0078 --- /dev/null +++ b/tests/features1921/java21/SwitchPatternPreview4OK.java @@ -0,0 +1,145 @@ +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); + + 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(); + } +*/ + + 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/new/.cvsignore b/tests/new/.cvsignore deleted file mode 100644 index 168aa3113e..0000000000 --- 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 189c180cff..0000000000 --- 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 a3f0b1b779..0000000000 --- a/tests/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java index 733102fbad..dee55718c6 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; 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 9d3c17f8d3..0000000000 --- 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/ajc160/SanityTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc160/SanityTests.java index 224e3e5992..4a7c39a012 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 c42a0cc251..ac5b109e66 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 d5505a252a..5d5a045641 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 fa2abafe5a..a8a3826ea8 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 329b3f8800..b0f2cdb672 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/AllTestsAspectJ1920.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/AllTestsAspectJ1920.java index c7962c2db3..a095eb7585 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/Bugs1920Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Bugs1920Tests.java index b1942f11bf..a87230f90e 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. *

* 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/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/Java20PreviewFeaturesTests.java index e597b32ec9..89a0a61c69 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/ajc1920/SanityTestsJava20.java b/tests/src/test/java/org/aspectj/systemtest/ajc1920/SanityTestsJava20.java index 09f52c1b7a..88b9670e95 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/ajc1921/Ajc1921TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java new file mode 100644 index 0000000000..b0eaf3939d --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Ajc1921TestsJava.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava21OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc1921TestsJava extends XMLBasedAjcTestCaseForJava21OrLater { + + 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() { + // 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"); + } + + public void testRecordPatternsPreview1Aspect() { + runTest("record patterns aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessAspect() { + // 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"); + } + + public void testRecordPatternsPreview1ExhaustivenessError() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + runTest("record patterns exhaustiveness error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK2() { + // 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() { + 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 0000000000..773ac90378 --- /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 0000000000..113731a4f7 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Bugs1921Tests.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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 testDummy() { + //runTest("dummy"); + } + + 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 0000000000..4b4de845d0 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava21Only; + +/** + * @author Alexander Kriegisch + */ +public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only { + + public void testDummyPreviewJava21() { + //runTest("dummy preview Java 21"); + } + + 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 0000000000..ed2216fdb9 --- /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/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java b/tests/src/test/java/org/aspectj/systemtest/ajc195/SanityTestsJava13.java index f8cffca691..54397cf2f2 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 6857b4d8ae..960ba44205 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 9622e73648..a7ee41d5fd 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 52950b4dd1..185660b152 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 0769be83b8..a9c247dadc 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 2fd9d2660a..a4c8ee9e25 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() { 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 9d3c17f8d3..0000000000 --- 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 9d3c17f8d3..0000000000 --- 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/ajc1920/ajc1920.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1920/ajc1920.xml index 86fa7db022..98a255088b 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 @@ - + - + + @@ -434,8 +437,8 @@ - - + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml new file mode 100644 index 0000000000..42a58da0c6 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 0000000000..e7da49fa1e --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/sanity-tests-21.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 9d3c17f8d3..0000000000 --- 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 a3f0b1b779..0000000000 --- a/util/src/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -*.lst diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 97676ea84f..43d100165c 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" * diff --git a/weaver/src/.cvsignore b/weaver/src/.cvsignore deleted file mode 100644 index defacf0999..0000000000 --- a/weaver/src/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bcweaver.lst -bcweaverSrc.lst

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