From eb56b6e84e24e58f318fb92479f9d9e6fa4c866f Mon Sep 17 00:00:00 2001 From: Andrew Clement Date: Fri, 7 Mar 2025 10:43:16 -0800 Subject: Add Java23 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The huge change with adopting Java23 is that 1.1 > 1.7 Java are now considered unsupported by Eclipse JDT, so the many thousands of tests we have that were specifying java versions lower than 1.8 were all failing with an unsupported version error. All those tests have had their versions bumped to 1.8.

That is why this commit includes so many changes. For example where we were specifying 1.5 - which was the case for many many generics/annotations tests, that is now 1.8. Also, some tests have been deleted because they make no sense now (verifying expected errors on Java 1.4 for example, errors that just can’t happen with minimum Java level 1.8). The biggest impact to tests was when bumping above 1.4 compliance suddenly there were 100s of adviceDidNotMatch messages. Some of these messages were actual indications of bad expectations in the test but many of them were just to-be-expected and were fixed either via an -Xlint:ignore option in the test spec or a SuppressAjWarnings in the test source.

One or two tests actually revealed real bugs that just didn’t surface with lower level java versions specified. A bare minimum of real Java 23 tests have been added just to get this sanity tested and committed. More would ideally be added. Other notable changes due to Eclipse JDT changes: org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/*.java Changes in here because there are now more validations on the code generator methods we were calling. Now you can’t start manipulating variables without having declared them as proper local variables, so those extra calls to define them have been added.
 org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom With needing to bump up the java versions, these classes had to be brought up to date with AST.JLS20 rather than only supporting versions 2/3. This was mostly copying patterns for the Eclipse classes.

 --- .../java/org/aspectj/ajde/core/JavaOptions.java | 2 + .../ajde/core/TestCompilerConfiguration.java | 4 +- .../ajde/core/tests/ShowWeaveMessagesTest.java | 14 +- .../aspectj/ajde/ui/swing/BrowserViewManager.java | 2 +- .../ajde/ui/utils/TestCompilerConfiguration.java | 41 +- .../test/java/org/aspectj/tools/ajdoc/BugTest.java | 4 +- lib/aspectj/lib/aspectjrt.jar | Bin 126631 -> 126638 bytes lib/aspectj/lib/aspectjtools.jar | Bin 15177853 -> 15327824 bytes lib/aspectj/lib/aspectjweaver.jar | Bin 2177100 -> 2181207 bytes .../java/org/aspectj/ajdt/ajc/BuildArgParser.java | 38 +- .../ajdt/internal/compiler/CommonPrinter.java | 4 +- .../internal/compiler/ast/AdviceDeclaration.java | 24 + .../internal/compiler/ast/AspectDeclaration.java | 64 +- .../compiler/ast/InterTypeFieldDeclaration.java | 38 + .../compiler/parser/DeclarationFactory.java | 3 +- .../aspectj/org/eclipse/jdt/core/dom/AjAST.java | 4 - .../org/eclipse/jdt/core/dom/AjASTConverter.java | 115 +- .../jdt/core/dom/AroundAdviceDeclaration.java | 3 + .../jdt/core/dom/InterTypeMethodDeclaration.java | 7 +- .../compiler/batch/messages_aspectj.properties | 2 +- .../aspectj/ajdt/ajc/BuildArgParserTestCase.java | 66 +- .../compiler/batch/DeclareParentsTest.java | 12 +- .../ajdt/internal/compiler/batch/JavadocTest.java | 2 +- .../internal/core/builder/AjBuildManagerTest.java | 22 +- .../ajdt/internal/core/builder/OutjarTest.java | 5 +- .../java/org/aspectj/tools/ajc/ASTVisitorTest.java | 7 +- .../java/org/aspectj/tools/ajc/ASTitdTest.java | 4 +- .../test/java/org/aspectj/tools/ajc/AjASTTest.java | 56 +- .../java/org/aspectj/tools/ajc/AjASTTestCase.java | 25 +- .../aspectj/tools/ajc/AjNaiveASTFlattenerTest.java | 4 +- .../java/org/aspectj/weaver/patterns/PerCflow.java | 9 +- pom.xml | 4 +- run-all-junit-tests/pom.xml | 6 + .../org/aspectj/tools/ant/taskdefs/AjcTask.java | 2 +- .../aspectj/tools/ant/taskdefs/AjcTaskTest.java | 2 +- testing/pom.xml | 7 + .../src/test/java/org/aspectj/testing/AjcTest.java | 9 +- .../testing/harness/bridge/CompilerRun.java | 26 +- .../testing/harness/bridge/ParseTestCase.java | 2 +- tests/ajcHarnessTests.xml | 37 +- tests/bugs/InterfaceConstructor.java | 4 +- tests/bugs/faultingInSource/SimpleTracing.java | 6 +- .../bugs162/pr242797/case3/GenericMethodAspect.aj | 2 +- .../bugs162/pr242797/case3/GenericMethodImpl.java | 5 +- .../bugs162/pr242797/case3/GenericMethodImpl2.java | 12 +- .../pr242797/case3/GenericMethodInterface.java | 7 +- tests/bugs162/pr242797/case3/Type1.java | 6 - tests/bugs162/pr242797/case3/Type2.java | 6 - tests/bugs163/pr163005/Code.java | 26 +- tests/cflow/CounterTest04.java | 8 +- tests/design/eachobject/Tricky3.java | 15 +- tests/design/intro/Interfaces.java | 70 +- tests/design/intro/Within.java | 44 +- tests/design/reflect/Coverage.java | 4 +- tests/errors/AroundReturnType.java | 15 +- tests/errors/CircularDominates.java | 8 +- .../java23/PrimitivePatternsSwitch1.java | 24 + .../java23/PrimitivePatternsSwitch2.java | 33 + tests/harness/ErrorTest.java | 2 +- tests/java5/bridgeMethods/AspectX.aj | 17 +- .../java5/generics/itds/bridgeMethods/pr91381_2.aj | 6 +- tests/java5/pertypewithin/H.java | 11 +- tests/new/AdviceOnEmptyConstructor.java | 4 +- tests/new/AfterReturningParam.java | 14 +- tests/new/AfterReturningParamMatching.java | 6 +- tests/new/ArgsAlone.java | 2 +- tests/new/AroundAll.java | 112 +- tests/new/ConstructorExecInitFails.java | 1 - tests/new/Counting1.java | 4 +- tests/new/EmptyInterfaceCE.java | 4 +- tests/new/FieldInitializerJoinPoints.java | 3 + tests/new/Fixes.java | 18 +- tests/new/IfFalse.aj | 6 +- tests/new/IfPCDAdviceMethods.java | 2 + tests/new/IfPCDDupMethod.java | 3 +- tests/new/IfTrue.aj | 5 +- tests/new/IndeterminateHandlerArg.java | 9 + tests/new/InitializerAdvice.java | 2 +- tests/new/IntroOnIntro.java | 4 +- tests/new/NegativeSourceLocation.java | 2 +- tests/new/NewAnonymous.java | 3 +- tests/new/NotCharInPointcut.java | 6 +- tests/new/PR353b.java | 15 +- tests/new/SourceLocationCall.java | 10 +- tests/new/StaticCalls.java | 1 + ...ticMethodsShouldNotReceiveInstanceofAdvice.java | 7 + tests/new/TypeDeclInAdvice.java | 3 +- tests/new/WithinInners.java | 2 + tests/new/access/psub/A.java | 7 +- .../privilegedAspects/driver/PrivilegedAspect.java | 4 +- .../java/org/aspectj/systemtest/AllTests14.java | 4 +- .../java/org/aspectj/systemtest/AllTests19.java | 4 +- .../org/aspectj/systemtest/ajc10x/Ajc10xTests.java | 21 +- .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 16 +- .../aspectj/systemtest/ajc150/GenericsTests.java | 5 +- .../ajc150/ataspectj/AtAjAnnotationGenTests.java | 4 - .../ajc152/SynchronizationTransformTests.java | 6 - .../ajc153/JDTLikeHandleProviderTests.java | 3 +- .../org/aspectj/systemtest/ajc160/SanityTests.java | 6 +- .../org/aspectj/systemtest/ajc161/Ajc161Tests.java | 7 +- .../aspectj/systemtest/ajc1610/NewFeatures.java | 21 +- .../org/aspectj/systemtest/ajc170/Ajc170Tests.java | 30 +- .../aspectj/systemtest/ajc190/SanityTests19.java | 4 +- .../systemtest/ajc191/SanityTestsJava10.java | 4 +- .../systemtest/ajc1919/SanityTestsJava19.java | 3 +- .../systemtest/ajc192/SanityTestsJava11.java | 4 +- .../systemtest/ajc1920/SanityTestsJava20.java | 3 +- .../systemtest/ajc1921/SanityTestsJava21.java | 3 +- .../systemtest/ajc1922/AllTestsAspectJ1922.java | 12 - .../systemtest/ajc1922/SanityTestsJava22.java | 3 +- .../systemtest/ajc1923/Ajc1923TestsJava.java | 40 + .../systemtest/ajc1923/AllTestsAspectJ1923.java | 52 + .../aspectj/systemtest/ajc1923/Bugs1923Tests.java | 31 + .../ajc1923/Java23PreviewFeaturesTests.java | 37 + .../systemtest/ajc1923/SanityTestsJava23.java | 91 ++ .../systemtest/ajc193/SanityTestsJava12.java | 4 +- .../systemtest/ajc195/SanityTestsJava13.java | 4 +- .../systemtest/ajc196/SanityTestsJava14.java | 3 +- .../systemtest/ajc197/SanityTestsJava15.java | 3 +- .../systemtest/ajc197/SanityTestsJava16.java | 3 +- .../systemtest/ajc198/SanityTestsJava17.java | 3 +- .../systemtest/ajc199/SanityTestsJava18.java | 3 +- .../tools/AnnotationProcessingTests.java | 18 +- .../tools/MultiProjTestCompilerConfiguration.java | 6 +- .../tools/MultiProjectIncrementalTests.java | 48 +- .../org/aspectj/systemtest/java14/Java14Tests.java | 2 +- .../org/aspectj/systemtest/xlint/XLintTests.java | 2 +- .../org/aspectj/systemtest/ajc10x/ajc10x.xml | 581 +++---- .../org/aspectj/systemtest/ajc11/ajc11.xml | 8 +- .../org/aspectj/systemtest/ajc120/ajc120.xml | 24 +- .../org/aspectj/systemtest/ajc121/ajc121.xml | 8 +- .../org/aspectj/systemtest/ajc150/ajc150.xml | 1650 ++++++++++---------- .../systemtest/ajc150/ataspectj/annotationgen.xml | 68 +- .../aspectj/systemtest/ajc150/ataspectj/ltw.xml | 85 +- .../aspectj/systemtest/ajc150/ataspectj/misuse.xml | 36 +- .../aspectj/systemtest/ajc150/ataspectj/syntax.xml | 84 +- .../org/aspectj/systemtest/ajc150/ltw/ltw.xml | 63 +- .../org/aspectj/systemtest/ajc151/ajc151.xml | 102 +- .../org/aspectj/systemtest/ajc151/ataround.xml | 68 +- .../systemtest/ajc151/newarray_joinpoint.xml | 28 +- .../aspectj/systemtest/ajc151/serialversionuid.xml | 8 +- .../org/aspectj/systemtest/ajc152/ajc152.xml | 156 +- .../aspectj/systemtest/ajc152/synchronization.xml | 98 +- .../org/aspectj/systemtest/ajc153/ajc153.xml | 159 +- .../systemtest/ajc153/jdtlikehandleprovider.xml | 30 +- .../org/aspectj/systemtest/ajc153/pipelining.xml | 8 +- .../org/aspectj/systemtest/ajc154/ajc154.xml | 126 +- .../org/aspectj/systemtest/ajc160/ajc160.xml | 50 +- .../systemtest/ajc160/annotationValueMatching.xml | 38 +- .../systemtest/ajc160/newfeatures-tests.xml | 5 +- .../systemtest/ajc160/parameterAnnotations.xml | 18 +- .../org/aspectj/systemtest/ajc160/sanity-tests.xml | 30 +- .../org/aspectj/systemtest/ajc161/ajc161.xml | 85 +- .../systemtest/ajc161/annotationFieldBinding.xml | 26 +- .../org/aspectj/systemtest/ajc1610/ajc1610.xml | 24 +- .../systemtest/ajc1610/newfeatures-tests.xml | 16 +- .../org/aspectj/systemtest/ajc1611/ajc1611.xml | 52 +- .../systemtest/ajc1611/newfeatures-tests.xml | 26 +- .../org/aspectj/systemtest/ajc1612/ajc1612.xml | 124 +- .../org/aspectj/systemtest/ajc162/ajc162.xml | 105 +- .../org/aspectj/systemtest/ajc163/ajc163.xml | 98 +- .../org/aspectj/systemtest/ajc164/ajc164.xml | 90 +- .../org/aspectj/systemtest/ajc164/declareMixin.xml | 42 +- .../org/aspectj/systemtest/ajc164/joinpointid.xml | 2 +- .../org/aspectj/systemtest/ajc165/ajc165.xml | 30 +- .../org/aspectj/systemtest/ajc166/ajc166.xml | 46 +- .../org/aspectj/systemtest/ajc167/ajc167.xml | 34 +- .../org/aspectj/systemtest/ajc167/intertype.xml | 12 +- .../org/aspectj/systemtest/ajc167/overweaving.xml | 46 +- .../org/aspectj/systemtest/ajc169/ajc169.xml | 108 +- .../org/aspectj/systemtest/ajc169/intertype.xml | 62 +- .../systemtest/ajc169/transparentweaving.xml | 28 +- .../org/aspectj/systemtest/ajc170/ajc170.xml | 106 +- .../org/aspectj/systemtest/ajc171/ajc171.xml | 24 +- .../systemtest/ajc171/newfeatures-tests.xml | 12 +- .../org/aspectj/systemtest/ajc172/ajc172.xml | 94 +- .../org/aspectj/systemtest/ajc173/ajc173.xml | 24 +- .../org/aspectj/systemtest/ajc174/ajc174.xml | 40 +- .../org/aspectj/systemtest/ajc175/ajc175.xml | 4 +- .../org/aspectj/systemtest/ajc181/ajc181.xml | 2 +- .../org/aspectj/systemtest/ajc1810/ajc1810.xml | 2 +- .../org/aspectj/systemtest/ajc183/ajc183.xml | 2 +- .../org/aspectj/systemtest/ajc185/ajc185.xml | 2 +- .../org/aspectj/systemtest/ajc186/ajc186.xml | 4 +- .../org/aspectj/systemtest/ajc188/ajc188.xml | 2 +- .../org/aspectj/systemtest/ajc189/ajc189.xml | 16 +- .../org/aspectj/systemtest/ajc190/ajc190.xml | 2 +- .../aspectj/systemtest/ajc190/sanity-tests-19.xml | 3 +- .../aspectj/systemtest/ajc191/sanity-tests-10.xml | 3 +- .../org/aspectj/systemtest/ajc1919/ajc1919.xml | 2 +- .../aspectj/systemtest/ajc1919/sanity-tests-19.xml | 3 +- .../aspectj/systemtest/ajc192/sanity-tests-11.xml | 3 +- .../org/aspectj/systemtest/ajc1920/ajc1920.xml | 22 +- .../aspectj/systemtest/ajc1920/sanity-tests-20.xml | 3 +- .../org/aspectj/systemtest/ajc1921/ajc1921.xml | 2 +- .../aspectj/systemtest/ajc1921/sanity-tests-21.xml | 3 +- .../aspectj/systemtest/ajc1922/sanity-tests-22.xml | 3 +- .../org/aspectj/systemtest/ajc1923/ajc1923.xml | 51 + .../aspectj/systemtest/ajc1923/sanity-tests-23.xml | 68 + .../org/aspectj/systemtest/ajc193/ajc193.xml | 2 +- .../aspectj/systemtest/ajc193/sanity-tests-12.xml | 3 +- .../aspectj/systemtest/ajc195/sanity-tests-13.xml | 3 +- .../org/aspectj/systemtest/ajc196/ajc196.xml | 2 +- .../aspectj/systemtest/ajc196/sanity-tests-14.xml | 3 +- .../aspectj/systemtest/ajc197/sanity-tests-15.xml | 3 +- .../aspectj/systemtest/ajc197/sanity-tests-16.xml | 3 +- .../org/aspectj/systemtest/ajc198/ajc198.xml | 2 +- .../aspectj/systemtest/ajc198/sanity-tests-17.xml | 3 +- .../org/aspectj/systemtest/ajc199/ajc199.xml | 12 +- .../aspectj/systemtest/ajc199/sanity-tests-18.xml | 3 +- .../org/aspectj/systemtest/apt/apt-spec.xml | 4 +- .../org/aspectj/systemtest/base/baseTests.xml | 3 +- .../org/aspectj/systemtest/design/design.xml | 12 +- .../aspectj/systemtest/incremental/incremental.xml | 2 +- .../incremental/model/incremental-model.xml | 2 +- .../org/aspectj/systemtest/java14/java14.xml | 46 +- .../org/aspectj/systemtest/model/model.xml | 16 +- .../org/aspectj/systemtest/pre10x/pre10x.xml | 14 +- .../systemtest/serialVerUID/serialVerUID.xml | 6 +- .../org/aspectj/systemtest/tracing/tracing.xml | 10 +- .../org/aspectj/systemtest/xlint/xlint.xml | 12 +- .../org/aspectj/weaver/bcel/AtAjAttributes.java | 27 +- .../org/aspectj/weaver/bcel/BcelTypeMunger.java | 18 +- .../java/org/aspectj/weaver/bcel/BcelWeaver.java | 6 + 224 files changed, 3857 insertions(+), 3228 deletions(-) create mode 100644 tests/features1923/java23/PrimitivePatternsSwitch1.java create mode 100644 tests/features1923/java23/PrimitivePatternsSwitch2.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1923/Ajc1923TestsJava.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1923/AllTestsAspectJ1923.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1923/Bugs1923Tests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1923/Java23PreviewFeaturesTests.java create mode 100644 tests/src/test/java/org/aspectj/systemtest/ajc1923/SanityTestsJava23.java create mode 100644 tests/src/test/resources/org/aspectj/systemtest/ajc1923/ajc1923.xml create mode 100644 tests/src/test/resources/org/aspectj/systemtest/ajc1923/sanity-tests-23.xml diff --git a/ajde.core/src/main/java/org/aspectj/ajde/core/JavaOptions.java b/ajde.core/src/main/java/org/aspectj/ajde/core/JavaOptions.java index 8ebaa664d..b51f6c025 100644 --- a/ajde.core/src/main/java/org/aspectj/ajde/core/JavaOptions.java +++ b/ajde.core/src/main/java/org/aspectj/ajde/core/JavaOptions.java @@ -28,6 +28,8 @@ public final class JavaOptions { public static final String VERSION_14 = CompilerOptions.VERSION_1_4; public static final String VERSION_15 = CompilerOptions.VERSION_1_5; public static final String VERSION_16 = CompilerOptions.VERSION_1_6; + public static final String VERSION_17 = CompilerOptions.VERSION_1_7; + public static final String VERSION_18 = CompilerOptions.VERSION_1_8; // by default will use the platform default encoding public static final String CHARACTER_ENCODING = CompilerOptions.OPTION_Encoding; diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java b/ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java index c7a63b5ba..b181aea5f 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/TestCompilerConfiguration.java @@ -77,8 +77,8 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { public Map getJavaOptionsMap() { if (javaOptions == null) { javaOptions = new Hashtable<>(); - javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); - javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); + javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_18); + javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_18); } return javaOptions; } diff --git a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java index 563f08666..5b1ecf78b 100644 --- a/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java +++ b/ajde.core/src/test/java/org/aspectj/ajde/core/tests/ShowWeaveMessagesTest.java @@ -166,8 +166,8 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { if (debugTests) System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Six.lst"); compilerConfig.setProjectSourceFiles(getSourceFileList(six)); - setRunIn15Mode(); - compilerConfig.setNonStandardOptions("-showWeaveInfo -1.5"); + setRunIn18Mode(); + compilerConfig.setNonStandardOptions("-showWeaveInfo -1.8"); doBuild(); assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty()); verifyWeavingMessages("declare.annotation", true); @@ -182,7 +182,7 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Seven.lst"); compilerConfig.setProjectSourceFiles(getSourceFileList(seven)); compilerConfig.setNonStandardOptions(""); - setRunIn15Mode(); + setRunIn18Mode(); doBuild(); assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty()); verifyWeavingMessages("declare.annotationNoWeaveInfo", true); @@ -423,11 +423,11 @@ public class ShowWeaveMessagesTest extends AjdeCoreTestCase { } } - private void setRunIn15Mode() { + private void setRunIn18Mode() { Map m = new Hashtable<>(); - m.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_15); - m.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15); - m.put(JavaOptions.TARGET_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15); + m.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_18); + m.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_18); + m.put(JavaOptions.TARGET_COMPATIBILITY_LEVEL, JavaOptions.VERSION_18); compilerConfig.setJavaOptions(m); } diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewManager.java index 300a56cd2..870de3843 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/swing/BrowserViewManager.java @@ -48,7 +48,7 @@ public class BrowserViewManager { private final GlobalViewProperties INHERITANCE_VIEW_PROPERTIES; public BrowserViewManager() { - java.util.List views = new ArrayList(); + java.util.List views = new ArrayList<>(); views.add(DECLARATION_VIEW); views.add(CROSSCUTTING_VIEW); views.add(INHERITANCE_VIEW); diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java index 53bd632af..93a061660 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java @@ -37,13 +37,13 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { private String projectPath; - private Set aspectpath; - private Set inpath; + private Set aspectpath; + private Set inpath; private String outjar; private Map javaOptions; private String nonStandardOptions; - private List projectSourceFiles = new ArrayList(); - private Map sourcePathResources; + private List projectSourceFiles = new ArrayList<>(); + private Map sourcePathResources; private String srcDirName = "src"; @@ -56,11 +56,11 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { public void configurationRead() { } - public List getProjectXmlConfigFiles() { - return Collections.EMPTY_LIST; + public List getProjectXmlConfigFiles() { + return Collections.emptyList(); } - public Set getAspectPath() { + public Set getAspectPath() { return aspectpath; } @@ -73,15 +73,15 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { return cp; } - public Set getInpath() { + public Set getInpath() { return inpath; } public Map getJavaOptionsMap() { if (javaOptions == null) { javaOptions = new Hashtable<>(); - javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); - javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); + javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_18); + javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_18); } return javaOptions; } @@ -101,17 +101,17 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { return outputLoc; } - public List getProjectSourceFiles() { + public List getProjectSourceFiles() { return projectSourceFiles; } - public List getProjectSourceFilesChanged() { + public List getProjectSourceFilesChanged() { return null; } - public Map getSourcePathResources() { + public Map getSourcePathResources() { if (sourcePathResources == null) { - sourcePathResources = new HashMap(); + sourcePathResources = new HashMap<>(); /* Allow the user to override the testProjectPath by using sourceRoots */ File[] srcBase = new File[] { new File(projectPath + File.separator + srcDirName) }; @@ -127,7 +127,6 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { for (File fromResource : fromResources) { String normPath = FileUtil.normalizedPath(fromResource, file); sourcePathResources.put(normPath, fromResource); - } } } @@ -135,11 +134,11 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { } // -------------------- setter methods useful for testing --------------- - public void setAspectPath(Set aspectPath) { + public void setAspectPath(Set aspectPath) { this.aspectpath = aspectPath; } - public void setInpath(Set inpath) { + public void setInpath(Set inpath) { this.inpath = inpath; } @@ -147,7 +146,7 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { this.outjar = outjar; } - public void setJavaOptions(Map javaOptions) { + public void setJavaOptions(Map javaOptions) { this.javaOptions = javaOptions; } @@ -155,11 +154,11 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { this.nonStandardOptions = options; } - public void setProjectSourceFiles(List projectSourceFiles) { + public void setProjectSourceFiles(List projectSourceFiles) { this.projectSourceFiles = projectSourceFiles; } - public void setSourcePathResources(Map sourcePathResources) { + public void setSourcePathResources(Map sourcePathResources) { this.sourcePathResources = sourcePathResources; } @@ -171,7 +170,7 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { return ICompilerConfiguration.EVERYTHING; } - public List getClasspathElementsWithModifiedContents() { + public List getClasspathElementsWithModifiedContents() { return null; } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java index 42d2c6f43..d41c1858d 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/BugTest.java @@ -37,7 +37,7 @@ public class BugTest extends AjdocTestCase { initialiseProject("pr148906"); File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")}; String[] ajOptions = {new String("-Xlint:error")}; - runAjdoc(files,"1.5",ajOptions); + runAjdoc(files,"1.8",ajOptions); assertTrue("expected ajc to fail but it did not", Main.hasAborted()); assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" + " failed instead with " + Main.getErrors()[0].getMessage(), @@ -53,7 +53,7 @@ public class BugTest extends AjdocTestCase { initialiseProject("pr148906"); File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")}; String[] ajOptions = {new String("-Xlintfile"), new String(getAbsoluteProjectDir() + File.separator + "Xlint.properties")}; - runAjdoc(files,"1.5",ajOptions); + runAjdoc(files,"1.8",ajOptions); assertTrue("expected ajc to fail but it did not", Main.hasAborted()); assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" + " failed instead with " + Main.getErrors()[0].getMessage(), diff --git a/lib/aspectj/lib/aspectjrt.jar b/lib/aspectj/lib/aspectjrt.jar index 1d86cc354..284b440b2 100644 Binary files a/lib/aspectj/lib/aspectjrt.jar and b/lib/aspectj/lib/aspectjrt.jar differ diff --git a/lib/aspectj/lib/aspectjtools.jar b/lib/aspectj/lib/aspectjtools.jar index a8e721e98..03a208aec 100644 Binary files a/lib/aspectj/lib/aspectjtools.jar and b/lib/aspectj/lib/aspectjtools.jar differ diff --git a/lib/aspectj/lib/aspectjweaver.jar b/lib/aspectj/lib/aspectjweaver.jar index 8cb9273da..dec44f869 100644 Binary files a/lib/aspectj/lib/aspectjweaver.jar and b/lib/aspectj/lib/aspectjweaver.jar differ diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java index 8548ce51e..99a642cc9 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -35,6 +35,7 @@ import org.aspectj.bridge.SourceLocation; import org.aspectj.bridge.Version; import org.aspectj.org.eclipse.jdt.core.compiler.CategorizedProblem; import org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.AptProblem; +import org.aspectj.org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.aspectj.org.eclipse.jdt.internal.compiler.batch.FileSystem; import org.aspectj.org.eclipse.jdt.internal.compiler.batch.Main; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; @@ -166,7 +167,8 @@ public class BuildArgParser extends Main { super.configure(javaArgList.toArray(new String[0])); if (parser.getModuleInfoArgument() != null) { - IModule moduleDesc = super.getModuleDesc(parser.getModuleInfoArgument()); + IModule moduleDesc = super.getModuleDesc(parser.getModuleInfoArgument(), + () -> new CompilationUnit(null, parser.getModuleInfoArgument(), null)); buildConfig.setModuleDesc(moduleDesc); } @@ -382,7 +384,7 @@ public class BuildArgParser extends Main { * If the classpath is not set, we use the environment's java.class.path, but remove the aspectjtools.jar entry from that list * in order to prevent wierd bootstrap issues (refer to bug#39959). */ - public List getClasspath(AjcConfigParser parser) { + public List getClasspath(AjcConfigParser parser) { List ret = new ArrayList<>(); // if (parser.bootclasspath == null) { @@ -904,14 +906,38 @@ public class BuildArgParser extends Main { } - @Override - public boolean checkVMVersion(long minimalSupportedVersion) { - return super.checkVMVersion(minimalSupportedVersion); - } +// @Override +// public boolean checkVMVersion(long minimalSupportedVersion) { +// return super.checkVMVersion(minimalSupportedVersion); +// } @Override public void initRootModules(LookupEnvironment environment, FileSystem fileSystem) { super.initRootModules(environment, fileSystem); } + + // Around Java23, looks like JDT has removed this and is just assuming 'modern' Java. + // This is what they had in org.eclipse.jdt.internal.compiler.batch.Main.checkVMVersion() + public boolean checkVMVersion(long minimalSupportedVersion) { + // the format of this property is supposed to be xx.x where x are digits. + String classFileVersion = System.getProperty("java.class.version"); //$NON-NLS-1$ + if (classFileVersion == null) { + // by default we don't support a class file version we cannot recognize + return false; + } + int index = classFileVersion.indexOf('.'); + if (index == -1) { + // by default we don't support a class file version we cannot recognize + return false; + } + int majorVersion; + try { + majorVersion = Integer.parseInt(classFileVersion.substring(0, index)); + } catch (NumberFormatException e) { + // by default we don't support a class file version we cannot recognize + return false; + } + return ClassFileConstants.getComplianceLevelForJavaVersion(majorVersion) >=minimalSupportedVersion; + } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java index 47be96344..eb5c43a8f 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/CommonPrinter.java @@ -768,14 +768,14 @@ public class CommonPrinter { printIndent(indent); if (statement.constantExpressions == null) { output.append("default "); //$NON-NLS-1$ - output.append(statement.isExpr ? "->" : ":"); //$NON-NLS-1$ //$NON-NLS-2$ + output.append(statement.isSwitchRule ? "->" : ":"); //$NON-NLS-1$ //$NON-NLS-2$ } else { output.append("case "); //$NON-NLS-1$ for (int i = 0, l = statement.constantExpressions.length; i < l; ++i) { printExpression(statement.constantExpressions[i]); if (i < l -1) output.append(','); } - output.append(statement.isExpr ? " ->" : " :"); //$NON-NLS-1$ //$NON-NLS-2$ + output.append(statement.isSwitchRule ? " ->" : " :"); //$NON-NLS-1$ //$NON-NLS-2$ } return output; } 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 8d10b3676..c91e1a424 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 @@ -27,6 +27,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; @@ -36,6 +37,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; @@ -209,6 +211,18 @@ public class AdviceDeclaration extends AjMethodDeclaration { for (int i = 0; i < nargs - 1; i++) { closureIndex += AstUtil.slotsNeeded(binding.parameters[i]); } + + Argument[] arguments = this.arguments; + if (arguments != null) { + for (Argument argument: arguments) { + LocalVariableBinding lvb = argument.binding; + LocalVariableBinding lvbCopy = new LocalVariableBinding(lvb.name, lvb.type, lvb.modifiers, true); + lvbCopy.declaration = new LocalDeclaration(argument.name, 0, 0); + codeStream.record(lvbCopy); + lvbCopy.recordInitializationStartPC(0); + lvbCopy.resolvedPosition = lvb.resolvedPosition; + } + } codeStream.aload(closureIndex); @@ -245,6 +259,16 @@ public class AdviceDeclaration extends AjMethodDeclaration { } AstUtil.generateReturn(returnType, codeStream); codeStream.recordPositionsFrom(0, 1); + + // tag the local variables as used throughout the method + if (arguments != null && codeStream.locals != null) { + for (int a = 0; a < arguments.length; a++) { + if (codeStream.locals[a] != null) { + codeStream.locals[a].recordInitializationEndPC(codeStream.position); + } + } + } + classFile.completeCodeAttribute(codeAttributeOffset,scope); attributeNumber++; classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); 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 ca61d85ae..724cb36a0 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 @@ -717,7 +717,9 @@ public class AspectDeclaration extends TypeDeclaration { .makeTypeBinding(UnresolvedType.JL_CLASS), Modifier.PUBLIC, true); codeStream.record(classVariable); classVariable.recordInitializationStartPC(codeStream.position); - ExceptionLabel goneBang = new ExceptionLabel(codeStream, world.makeTypeBinding(UnresolvedType.JL_EXCEPTION)); + + TypeBinding exceptionTypeBinding = world.makeTypeBinding(UnresolvedType.JL_EXCEPTION); + ExceptionLabel goneBang = new ExceptionLabel(codeStream, exceptionTypeBinding); BranchLabel noInstanceExists = new BranchLabel(codeStream); BranchLabel leave = new BranchLabel(codeStream); goneBang.placeStart(); @@ -735,6 +737,7 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.ireturn(); goneBang.place(); //codeStream.astore_1(); + codeStream.pushExceptionOnStack(exceptionTypeBinding); codeStream.pop(); codeStream.iconst_0(); codeStream.ireturn(); @@ -869,18 +872,31 @@ public class AspectDeclaration extends TypeDeclaration { generateMethod(classFile, AjcMemberMaker.perTypeWithinCreateAspectInstance(world.fromBinding(binding)), new BodyGenerator() { public void generate(CodeStream codeStream) { - - codeStream.new_(world.makeTypeBinding(typeX)); + TypeBinding aspectType = world.makeTypeBinding(typeX); + LocalVariableBinding perTypeName = new LocalVariableBinding("perTypeName".toCharArray(), world + .makeTypeBinding(UnresolvedType.JL_STRING), Modifier.PUBLIC, true); + codeStream.record(perTypeName); + perTypeName.resolvedPosition = 0; + perTypeName.recordInitializationStartPC(codeStream.position); + + codeStream.new_(aspectType); codeStream.dup(); codeStream.invoke(Opcodes.OPC_invokespecial, new MethodBinding(0, "".toCharArray(), TypeBinding.VOID, new TypeBinding[0], new ReferenceBinding[0], binding), null); - codeStream.astore_1(); + codeStream.astore_1(); // This is a local variable at this point + LocalVariableBinding aspectInstanceVariable = new LocalVariableBinding("aspectInstance".toCharArray(), aspectType, Modifier.PUBLIC, true); + codeStream.record(aspectInstanceVariable); + aspectInstanceVariable.resolvedPosition = 1; + aspectInstanceVariable.recordInitializationStartPC(codeStream.position); + codeStream.aload_1(); codeStream.aload_0(); codeStream.fieldAccess(Opcodes.OPC_putfield, world.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX, typeX)), null); codeStream.aload_1(); codeStream.areturn(); + aspectInstanceVariable.recordInitializationEndPC(codeStream.position); + perTypeName.recordInitializationEndPC(codeStream.position); } }); } @@ -1001,37 +1017,59 @@ public class AspectDeclaration extends TypeDeclaration { generateMethod(classFile, accessField.reader, makeEffectiveSignatureAttribute(field, Shadow.FieldGet, false), new BodyGenerator() { public void generate(CodeStream codeStream) { - // body starts here if (Modifier.isStatic(field.getModifiers())) { codeStream.fieldAccess(Opcodes.OPC_getstatic, fieldBinding, null); + AstUtil.generateReturn(accessField.reader.returnType, codeStream); } else { + LocalVariableBinding declaringTypeVar = + new LocalVariableBinding("declaringType".toCharArray(), accessField.declaringClass, + Modifier.PUBLIC, true); + codeStream.record(declaringTypeVar); + declaringTypeVar.recordInitializationStartPC(codeStream.position); codeStream.aload_0(); codeStream.fieldAccess(Opcodes.OPC_getfield, fieldBinding, null); + AstUtil.generateReturn(accessField.reader.returnType, codeStream); + declaringTypeVar.recordInitializationEndPC(codeStream.position); } - - AstUtil.generateReturn(accessField.reader.returnType, codeStream); - // body ends here } }); generateMethod(classFile, accessField.writer, makeEffectiveSignatureAttribute(field, Shadow.FieldSet, false), new BodyGenerator() { public void generate(CodeStream codeStream) { - // body starts here if (Modifier.isStatic(field.getModifiers())) { + LocalVariableBinding fieldValueVar = + new LocalVariableBinding("fieldValue".toCharArray(), accessField.type, + Modifier.PUBLIC, true); + codeStream.record(fieldValueVar); + fieldValueVar.resolvedPosition = 0; + fieldValueVar.recordInitializationStartPC(codeStream.position); codeStream.load(fieldBinding.type, 0); codeStream.fieldAccess(Opcodes.OPC_putstatic, fieldBinding, null); + codeStream.return_(); + fieldValueVar.recordInitializationEndPC(codeStream.position); } else { + LocalVariableBinding declaringTypeVar = + new LocalVariableBinding("instance".toCharArray(), accessField.declaringClass, + Modifier.PUBLIC, true); + codeStream.record(declaringTypeVar); + declaringTypeVar.recordInitializationStartPC(codeStream.position); + declaringTypeVar.resolvedPosition = 0; + LocalVariableBinding fieldValueVar = + new LocalVariableBinding("value".toCharArray(), accessField.type, + Modifier.PUBLIC, true); + codeStream.record(fieldValueVar); + fieldValueVar.recordInitializationStartPC(codeStream.position); + fieldValueVar.resolvedPosition = 1; codeStream.aload_0(); codeStream.load(fieldBinding.type, 1); codeStream.fieldAccess(Opcodes.OPC_putfield, fieldBinding, null); + fieldValueVar.recordInitializationEndPC(codeStream.position); + codeStream.return_(); + declaringTypeVar.recordInitializationEndPC(codeStream.position); } - - codeStream.return_(); - // body ends here } }); - } private void generateInlineAccessMethod(ClassFile classFile, final MethodBinding accessMethod, final ResolvedMember method) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index be76db385..ea3e58030 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -26,6 +26,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpressi import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; @@ -34,6 +35,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; @@ -354,6 +356,20 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { munger.getTypeVariableAliases()); codeStream.initializeMaxLocals(binding); + + Argument[] itdArgs = this.arguments; + if (itdArgs != null) { + for (Argument itdArg : itdArgs) { + LocalVariableBinding lvb = itdArg.binding; + LocalVariableBinding lvbCopy = new LocalVariableBinding(lvb.name, lvb.type, lvb.modifiers, true); + lvbCopy.declaration = new LocalDeclaration(itdArg.name, 0, 0); + lvbCopy.declaringScope = scope; + codeStream.record(lvbCopy); + lvbCopy.recordInitializationStartPC(0); + lvbCopy.resolvedPosition = lvb.resolvedPosition; + } + } + if (isGetter) { if (onTypeBinding.isInterface()) { UnresolvedType declaringTX = sig.getDeclaringType(); @@ -377,6 +393,15 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { } AstUtil.generateReturn(binding.returnType, codeStream); + // tag the local variables as used throughout the method + if (itdArgs != null && codeStream.locals != null) { + for (int a = 0; a < itdArgs.length; a++) { + if (codeStream.locals[a] != null) { + codeStream.locals[a].recordInitializationEndPC(codeStream.position); + } + } + } + classFile.completeCodeAttribute(codeAttributeOffset,scope); attributeNumber++; classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); @@ -432,9 +457,22 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { codeStream.load(field.type, 0); codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.writer,null); } else { + // Example: + // We are generating: public static void ajc$interFieldSetDispatch$PersonAspect$Manager$jobTitle(Manager, java.lang.String) + // And it is calling: public static void ajc$set$jobTitle(Manager, java.lang.String) + LocalVariableBinding instanceVar = new LocalVariableBinding("instance".toCharArray(),this.onTypeBinding,Modifier.PUBLIC,true); + codeStream.record(instanceVar); + instanceVar.recordInitializationStartPC(codeStream.position); + instanceVar.resolvedPosition = 0; codeStream.aload_0(); + LocalVariableBinding valueVar = new LocalVariableBinding("value".toCharArray(),this.realFieldType,Modifier.PUBLIC,true); + codeStream.record(valueVar); + valueVar.recordInitializationStartPC(codeStream.position); + valueVar.resolvedPosition = 1; codeStream.load(field.type, 1); codeStream.invoke(Opcodes.OPC_invokestatic,fBinding.writer,null); + instanceVar.recordInitializationEndPC(codeStream.position); + valueVar.recordInitializationEndPC(codeStream.position); } return; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java index 31890fcdb..5a1d77774 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/parser/DeclarationFactory.java @@ -75,9 +75,10 @@ public class DeclarationFactory implements IDeclarationFactory { public void setPerClauseFrom(TypeDeclaration aspectDecl, ASTNode pseudoTokens, Parser parser) { AspectDeclaration aspect = (AspectDeclaration) aspectDecl; PseudoTokens tok = (PseudoTokens) pseudoTokens; + int start = parser.getCurrentTokenStart(); aspect.perClause = tok.parsePerClause(parser); // For the ast support: currently the below line is not finished! The start is set incorrectly - ((AspectDeclaration) aspectDecl).perClause.setLocation(null, 1, parser.getCurrentTokenStart() + 1); + ((AspectDeclaration) aspectDecl).perClause.setLocation(null, start, parser.getCurrentTokenStart() + 1); } public void setDominatesPatternFrom(TypeDeclaration aspectDecl, ASTNode pseudoTokens, Parser parser) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java index 8aa4bc8ba..c1a6229ca 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjAST.java @@ -44,10 +44,6 @@ public class AjAST extends AST { * @since 3.0 */ public static AjAST newAjAST(int level,boolean previewEnabled) { - if ((level != AST.JLS2) - && (level != AST.JLS3)) { - throw new IllegalArgumentException(); - } return new AjAST(level,previewEnabled); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java index 9fe28b7d4..72edb9fa0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java @@ -305,8 +305,13 @@ public class AjASTConverter extends ASTConverter { Type returnType = convertType(typeReference); // get the positions of the right parenthesis int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(end, method.bodyEnd); - int extraDimensions = retrieveExtraDimension(rightParenthesisPosition, method.bodyEnd); - methodDecl.setExtraDimensions(extraDimensions); + int extraDimensions = typeReference.extraDimensions(); + if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { + setExtraAnnotatedDimensions(rightParenthesisPosition, method.bodyEnd, typeReference, + methodDecl.extraDimensions(), extraDimensions); + } else { + internalSetExtraDimensions(methodDecl, extraDimensions); + } setTypeForMethodDeclaration(methodDecl, returnType, extraDimensions); } else { // no return type for a method that is not a constructor @@ -1029,8 +1034,15 @@ public class AjASTConverter extends ASTConverter { name.setSourceRange(start, nameEnd - start + 1); variableDecl.setName(name); final int typeSourceEnd = argument.type.sourceEnd; - final int extraDimensions = retrieveExtraDimension(nameEnd + 1, typeSourceEnd); - variableDecl.setExtraDimensions(extraDimensions); + TypeReference typeReference = argument.type; + final int extraDimensions = typeReference.extraDimensions(); + if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { + setExtraAnnotatedDimensions(nameEnd + 1, typeSourceEnd, typeReference, + variableDecl.extraDimensions(), extraDimensions); + } else { + internalSetExtraDimensions(variableDecl, extraDimensions); + } + final boolean isVarArgs = argument.isVarArgs(); if (isVarArgs && extraDimensions == 0) { // remove the ellipsis from the type source end @@ -1068,6 +1080,33 @@ public class AjASTConverter extends ASTConverter { } return variableDecl; } + + /** + * Internal access method to SingleVariableDeclaration#setExtraDimensions() for avoiding deprecated warnings + * + * @deprecated + */ + private static void internalSetExtraDimensions(SingleVariableDeclaration node, int dimensions) { + node.setExtraDimensions(dimensions); + } + + /** + * Internal access method to MethodDeclaration#setExtraDimension() for avoiding deprecated warnings + * + * @deprecated + */ + private static void internalSetExtraDimensions(MethodDeclaration node, int dimensions) { + node.setExtraDimensions(dimensions); + } + + /** + * Internal access method to VariableDeclarationFragment#setExtraDimensions() for avoiding deprecated warnings + * + * @deprecated + */ + private static void internalSetExtraDimensions(VariableDeclarationFragment node, int dimensions) { + node.setExtraDimensions(dimensions); + } // public Annotation convert(org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation annotation) { // if (annotation instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation) { @@ -2741,8 +2780,19 @@ public class AjASTConverter extends ASTConverter { } else { variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, - fieldDeclaration.declarationSourceEnd)); + + TypeReference typeReference = fieldDeclaration.returnType; + int extraDimensions = typeReference.extraDimensions(); + if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { + setExtraAnnotatedDimensions(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd, + typeReference, variableDeclarationFragment.extraDimensions(), extraDimensions); + } else { + internalSetExtraDimensions(variableDeclarationFragment, extraDimensions); + } +// variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, +// fieldDeclaration.declarationSourceEnd)); + + if (this.resolveBindings) { recordNodes(name, fieldDeclaration); recordNodes(variableDeclarationFragment, fieldDeclaration); @@ -2772,8 +2822,14 @@ public class AjASTConverter extends ASTConverter { } else { variableDeclarationFragment.setSourceRange(fieldDeclaration.sourceStart, end - fieldDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(fieldDeclaration.sourceEnd + 1, - fieldDeclaration.declarationSourceEnd)); + TypeReference typeReference = fieldDeclaration.type; + int extraDimensions = typeReference.extraDimensions(); + if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { + setExtraAnnotatedDimensions(fieldDeclaration.sourceEnd + 1, fieldDeclaration.declarationSourceEnd, + typeReference, variableDeclarationFragment.extraDimensions(), extraDimensions); + } else { + internalSetExtraDimensions(variableDeclarationFragment, extraDimensions); + } if (this.resolveBindings) { recordNodes(name, fieldDeclaration); recordNodes(variableDeclarationFragment, fieldDeclaration); @@ -2807,8 +2863,25 @@ public class AjASTConverter extends ASTConverter { } else { variableDeclarationFragment.setSourceRange(localDeclaration.sourceStart, end - localDeclaration.sourceStart + 1); } - variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, - this.compilationUnitSourceLength)); + + TypeReference typeReference; + int extraDimension; + if(localDeclaration.type != null) { + typeReference = localDeclaration.type; + extraDimension = typeReference.extraDimensions(); + } else { + typeReference = null; + extraDimension = 0; + } + if (this.ast.apiLevel >= AST.JLS8_INTERNAL) { + setExtraAnnotatedDimensions(localDeclaration.sourceEnd + 1, this.compilationUnitSourceLength, + typeReference, variableDeclarationFragment.extraDimensions(), extraDimension); + } else { + internalSetExtraDimensions(variableDeclarationFragment, extraDimension); + } + +// variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, +// this.compilationUnitSourceLength)); if (this.resolveBindings) { recordNodes(variableDeclarationFragment, localDeclaration); recordNodes(name, localDeclaration); @@ -4055,7 +4128,7 @@ public class AjASTConverter extends ASTConverter { enumConstantDeclaration.setFlags(enumConstantDeclaration.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(fieldDeclaration.declarationSourceStart, fieldDeclaration.sourceStart); this.setModifiers(enumConstantDeclaration, fieldDeclaration.annotations); } @@ -4074,7 +4147,7 @@ public class AjASTConverter extends ASTConverter { fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); this.setModifiers(fieldDeclaration, fieldDecl.annotations); } @@ -4090,7 +4163,7 @@ public class AjASTConverter extends ASTConverter { fieldDeclaration.setFlags(fieldDeclaration.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(fieldDecl.declarationSourceStart, fieldDecl.sourceStart); this.setModifiers(fieldDeclaration, fieldDecl.annotations); } @@ -4109,7 +4182,7 @@ public class AjASTConverter extends ASTConverter { initializer.setFlags(initializer.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(oldInitializer.declarationSourceStart, oldInitializer.bodyStart); this.setModifiers(initializer, oldInitializer.annotations); } @@ -4132,7 +4205,7 @@ public class AjASTConverter extends ASTConverter { methodDecl.setFlags(methodDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(methodDeclaration.declarationSourceStart, methodDeclaration.sourceStart); this.setModifiers(methodDecl, methodDeclaration.annotations); } @@ -4148,7 +4221,7 @@ public class AjASTConverter extends ASTConverter { pointcutDecl.setFlags(pointcutDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(pointcutDeclaration.declarationSourceStart, pointcutDeclaration.sourceStart); this.setModifiers(pointcutDecl, pointcutDeclaration.annotations); } @@ -4166,7 +4239,7 @@ public class AjASTConverter extends ASTConverter { variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(argument.declarationSourceStart, argument.sourceStart); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = argument.annotations; int indexInAnnotations = 0; @@ -4241,7 +4314,7 @@ public class AjASTConverter extends ASTConverter { variableDecl.setFlags(variableDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; int indexInAnnotations = 0; @@ -4324,7 +4397,7 @@ public class AjASTConverter extends ASTConverter { typeDecl.setFlags(typeDecl.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(typeDeclaration.declarationSourceStart, typeDeclaration.sourceStart); this.setModifiers(typeDecl, typeDeclaration.annotations); } @@ -4344,7 +4417,7 @@ public class AjASTConverter extends ASTConverter { variableDeclarationExpression.setFlags(variableDeclarationExpression.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; int indexInAnnotations = 0; @@ -4425,7 +4498,7 @@ public class AjASTConverter extends ASTConverter { variableDeclarationStatement.setFlags(variableDeclarationStatement.getFlags() | ASTNode.MALFORMED); } break; - case AST.JLS3: + default: this.scanner.resetTo(localDeclaration.declarationSourceStart, localDeclaration.sourceStart); org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation[] annotations = localDeclaration.annotations; int indexInAnnotations = 0; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java index 95d7bda67..3aec4cd60 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AroundAdviceDeclaration.java @@ -141,6 +141,9 @@ public class AroundAdviceDeclaration extends AdviceDeclaration { return this.typeParameters; } + /** + * @deprecated + */ public Type getReturnType() { return internalGetReturnType(); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java index 7439f3eb8..da25e2fbe 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/InterTypeMethodDeclaration.java @@ -96,7 +96,12 @@ public class InterTypeMethodDeclaration extends MethodDeclaration { // n.b. visit return type even for constructors acceptChild(ajvis, getName()); acceptChildren(ajvis, this.parameters); - acceptChildren(ajvis, (NodeList)this.thrownExceptions()); + if (this.ast.apiLevel() >= AST.JLS8_INTERNAL) { + acceptChildren(visitor, (NodeList)this.extraDimensions()); + acceptChildren(visitor, (NodeList)this.thrownExceptionTypes()); + } else { + acceptChildren(visitor, (NodeList)this.thrownExceptions()); + } acceptChild(ajvis, getBody()); } ajvis.endVisit(this); 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 1851bb076..37b3e7b1d 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,7 +1,7 @@ compiler.name = AspectJ Compiler # AspectJ_JDK_Update: Update not only for new Java versions, but each time JDT Core is updated with an upstream merge. # Always make sure to update to the latest merge commit ID and date of the latest upstream commit. -compiler.version = Eclipse Compiler b2705b00e91be7 (20Mar2024) - Java22 +compiler.version = Eclipse Compiler 261e7fa1c2f057 (4Feb2025) - Java23 compiler.copyright = misc.version = {0} {1} - {2} {3} diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java index 916a5abe8..90d5d8e56 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/ajc/BuildArgParserTestCase.java @@ -66,9 +66,8 @@ public class BuildArgParserTestCase extends TestCase { assertTrue( config.getClasspath().toString(), config.getClasspath().contains("2.jar")); - - config = genBuildConfig(new String[] { "-1.3" }, messageWriter); - // these errors are deffered to the compiler now + config = genBuildConfig(new String[] { "-1.8" }, messageWriter); + // these errors are defered to the compiler now //err = parser.getOtherMessages(true); //!!!assertTrue(err, null == err); assertTrue( @@ -79,7 +78,7 @@ public class BuildArgParserTestCase extends TestCase { config.getClasspath().contains("2.jar")); parser = new BuildArgParser(messageWriter); - config = parser.genBuildConfig(new String[] { "-1.3" }); + config = parser.genBuildConfig(new String[] { "-1.8" }); /*err = */parser.getOtherMessages(true); //!!!assertTrue(err, null == err); assertTrue( @@ -89,12 +88,11 @@ public class BuildArgParserTestCase extends TestCase { config.getClasspath().toString(), config.getClasspath().contains("2.jar")); - config = genBuildConfig(new String[] { - "-classpath", ENTRY, "-1.4" }, messageWriter); - // these errors are deffered to the compiler now + config = genBuildConfig(new String[] {"-classpath", ENTRY, "-1.8" }, messageWriter); + // these errors are defered to the compiler now //err = parser.getOtherMessages(true); //assertTrue("expected errors for missing jars", null != err); - List cp = config.getClasspath(); + List cp = config.getClasspath(); boolean jar1Found = false; boolean jar2Found = false; for (Object o : cp) { @@ -102,13 +100,8 @@ public class BuildArgParserTestCase extends TestCase { if (element.contains("1.jar")) jar1Found = true; if (element.contains("2.jar")) jar2Found = true; } - assertTrue( - config.getClasspath().toString(), - jar1Found); - assertTrue( - config.getClasspath().toString(), - jar2Found); - + assertTrue(config.getClasspath().toString(),jar1Found); + assertTrue(config.getClasspath().toString(),jar2Found); } finally { // do finally to avoid messing up classpath for other tests System.setProperty("java.class.path", classpath); @@ -287,7 +280,7 @@ public class BuildArgParserTestCase extends TestCase { assertEquals(getCanonicalPath(new File(SRCROOT)), config.getSourceRoots().get(0).getAbsolutePath()); - Collection expectedFiles = Arrays.asList(new File[] { + Collection expectedFiles = Arrays.asList(new File[] { new File(SRCROOT+File.separator+"Hello.java").getCanonicalFile(), new File(Constants.TESTDATA_PATH +File.separator+"src1"+File.separator+"A.java").getCanonicalFile(), }); @@ -347,10 +340,10 @@ public class BuildArgParserTestCase extends TestCase { //XXX shouldn't need -1.4 to get this to pass public void testCombinedOptions() throws InvalidInputException { - AjBuildConfig config = genBuildConfig(new String[] { "-Xlint:error", "-target", "1.4"}, messageWriter); + AjBuildConfig config = genBuildConfig(new String[] { "-Xlint:error", "-target", "1.8"}, messageWriter); assertTrue( "target set", - config.getOptions().targetJDK == ClassFileConstants.JDK1_4); + config.getOptions().targetJDK == ClassFileConstants.JDK1_8); assertTrue( "Xlint option set", @@ -434,38 +427,11 @@ public class BuildArgParserTestCase extends TestCase { assertEquals(getCanonicalPath(new File(lintFile)),config.getLintSpecFile().getAbsolutePath()); } - /** - * The option '-1.5' are currently eaten by the AspectJ argument parser - since - * the JDT compiler upon which we are based doesn't understand them - *this should change* when we - * switch to a 1.5 compiler base. They are currently used to determine whether the weaver should - * behave in a '1.5' way - for example autoboxing behaves differently when the 1.5 flag is specified. - * Under 1.4 Integer != int - * Under 1.5 Integer == int - * (this applies to all primitive types) - */ - public void testSource15() throws InvalidInputException { -// AjBuildConfig config = genBuildConfig(new String[]{"-source","1.5"},messageWriter); -// assertTrue("should be in 1.5 mode",config.getJave5Behaviour()); - AjBuildConfig config = genBuildConfig(new String[]{"-1.5"},messageWriter); - assertTrue("should be in 1.5 mode",config.getBehaveInJava5Way()); - config = genBuildConfig(new String[]{"-source","1.4"},messageWriter); - assertTrue("should not be in 1.5 mode",!config.getBehaveInJava5Way()); - assertTrue("should be in 1.4 mode",config.getOptions().sourceLevel == ClassFileConstants.JDK1_4); - config = genBuildConfig(new String[]{"-source","1.3"},messageWriter); - assertTrue("should not be in 1.5 mode",!config.getBehaveInJava5Way()); - assertTrue("should be in 1.3 mode",config.getOptions().sourceLevel == ClassFileConstants.JDK1_3); - } - public void testOptions() throws InvalidInputException { -// AjdtCommand command = new AjdtCommand(); - String TARGET = "1.4"; + String TARGET = "1.8"; AjBuildConfig config = genBuildConfig(new String[] {"-target", TARGET, "-source", TARGET}, messageWriter); - assertTrue( - "target set", - config.getOptions().targetJDK == ClassFileConstants.JDK1_4); - assertTrue( - "source set", - config.getOptions().sourceLevel == ClassFileConstants.JDK1_4); + assertTrue("target set",config.getOptions().targetJDK == ClassFileConstants.JDK1_8); + assertTrue("source set",config.getOptions().sourceLevel == ClassFileConstants.JDK1_8); } public void testLstFileExpansion() throws IOException, FileNotFoundException, InvalidInputException { @@ -473,10 +439,8 @@ public class BuildArgParserTestCase extends TestCase { String SOURCE_PATH_1 = "A.java"; String SOURCE_PATH_2 = "B.java"; -// File f = new File(FILE_PATH); - AjBuildConfig config = genBuildConfig(new String[] { "@" + FILE_PATH }, messageWriter); - List resultList = config.getFiles(); + List resultList = config.getFiles(); assertTrue("correct number of files", resultList.size() == 2); assertTrue(resultList.toString() + new File(TEST_DIR + SOURCE_PATH_1).getCanonicalFile(), diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java index 4f742a140..e74bbafe4 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/DeclareParentsTest.java @@ -230,7 +230,7 @@ public class DeclareParentsTest extends AjcTestCase { String[] sourceCompileCommandLine = new String[classes.length + aspects.length + 2]; System.arraycopy(classes, 0, sourceCompileCommandLine, 0, classes.length); System.arraycopy(aspects, 0, sourceCompileCommandLine, classes.length, aspects.length); - String[] extraOption = new String[] { "-showWeaveInfo", "-1.4"}; + String[] extraOption = new String[] { "-showWeaveInfo", "-1.8"}; System.arraycopy(extraOption, 0, sourceCompileCommandLine, classes.length + aspects.length, 2); result = ajc(testBase, sourceCompileCommandLine); if (!expectErrors) @@ -258,7 +258,7 @@ public class DeclareParentsTest extends AjcTestCase { assertTrue("Should get no errors for this compile, but got: " + result.getErrorMessages().size(), result.getErrorMessages() .size() == 0); // Execute: "ajc -inpath classes -showWeaveInfo -d classes2 -aspectpath aspects.jar" - result = ajc(testBase, new String[] { "-inpath", "classes", "-showWeaveInfo", "-1.4", "-d", "classes2", "-aspectpath", + result = ajc(testBase, new String[] { "-inpath", "classes", "-showWeaveInfo", "-1.8", "-d", "classes2", "-aspectpath", "aspects.jar" }); if (!expectErrors) @@ -274,6 +274,14 @@ public class DeclareParentsTest extends AjcTestCase { System.err.println("Binary Compilation: Weaving count = " + binaryWeaveMessagesCount + "\n" + binaryWeaveMessages); System.err.println("StandardError from final binary compile stage: " + result.getStandardError()); } + + if (sourceErrorMessagesCount!=binaryErrorMessagesCount) { + System.err.println("Source Compilation: Error count = " + sourceErrorMessagesCount + "\n" + sourceErrorMessages); + System.err.println("Source Compilation: Weaving count = " + sourceWeaveMessagesCount + "\n" + sourceWeaveMessages); + System.err.println("Binary Compilation: Error count = " + binaryErrorMessagesCount + "\n" + binaryErrorMessages); + System.err.println("Binary Compilation: Weaving count = " + binaryWeaveMessagesCount + "\n" + binaryWeaveMessages); + System.err.println("StandardError from final binary compile stage: " + result.getStandardError()); + } assertTrue("Should have same number of errors in either case: " + sourceErrorMessagesCount + "!=" + binaryErrorMessagesCount, sourceErrorMessagesCount == binaryErrorMessagesCount); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/JavadocTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/JavadocTest.java index 284d97545..88259d189 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/JavadocTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/compiler/batch/JavadocTest.java @@ -35,7 +35,7 @@ public class JavadocTest extends AjcTestCase { * */ public void testMissingJavadoc() { - String[] args = new String[] { "World.java", "-warn:allJavadoc", "-1.4" }; + String[] args = new String[] { "World.java", "-warn:allJavadoc", "-Xlint:ignore", "-1.8" }; List warningMessages = new ArrayList<>(); // These warnings are against public textX() methods declared in the World.java diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java index 9b7700650..c4bb761ea 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/AjBuildManagerTest.java @@ -16,7 +16,6 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import org.aspectj.ajdt.StreamPrintWriter; import org.aspectj.ajdt.ajc.BuildArgParser; import org.aspectj.ajdt.ajc.Constants; import org.aspectj.bridge.IMessage; @@ -24,12 +23,12 @@ import org.aspectj.bridge.MessageHandler; import org.aspectj.bridge.MessageWriter; import org.aspectj.testing.util.TestUtil; +import junit.framework.AssertionFailedError; import junit.framework.TestCase; public class AjBuildManagerTest extends TestCase { - private final StreamPrintWriter outputWriter = new StreamPrintWriter(new PrintWriter(System.out)); - private final MessageWriter messageWriter = new MessageWriter(outputWriter, false); + private final MessageWriter messageWriter = new MessageWriter(new PrintWriter(System.out), false); public static File source1 = new File(Constants.TESTDATA_DIR, "src1/A.java"); public static File source2 = new File(Constants.TESTDATA_DIR, "src1/Hello.java"); public static File source3 = new File(Constants.TESTDATA_DIR, "src1/X.java"); @@ -44,10 +43,17 @@ public class AjBuildManagerTest extends TestCase { if (1 == numMessages) { // permit aspectjrt.jar warning IMessage m = handler.getMessages(IMessage.WARNING, true)[0]; if (!(m.isWarning() && (m.getMessage().contains("aspectjrt.jar")))) { - assertTrue(handler.toString(), false); + fail("Unexpected warning: "+m); } } else if (0 != numMessages) { - assertTrue(handler.toString(), false); + // Unexpected warnings + IMessage[] warningMessages = handler.getMessages(IMessage.WARNING, false); + System.out.println("There are "+warningMessages.length+" unexpected warnings:"); + int m = 1; + for (IMessage warningMessage: warningMessages) { + System.out.println((m++)+") "+warningMessage); + } + fail(); } } @@ -60,10 +66,8 @@ public class AjBuildManagerTest extends TestCase { BuildArgParser parser = new BuildArgParser(messageWriter); String javaClassPath = System.getProperty("java.class.path"); String sandboxName = TestUtil.createEmptySandbox().getAbsolutePath(); - AjBuildConfig buildConfig = parser.genBuildConfig(new String[] { "-d", sandboxName, "-1.4", "-classpath", javaClassPath, - Constants.TESTDATA_PATH + "/src1/A.java", - // EajcModuleTests.TESTDATA_PATH + "/src1/Hello.java", - }); + AjBuildConfig buildConfig = parser.genBuildConfig(new String[] { "-d", sandboxName, "-1.8", "-Xlint:ignore", "-classpath", javaClassPath, + Constants.TESTDATA_PATH + "/src1/A.java"}); String err = parser.getOtherMessages(true); assertTrue(err, null == err || err.startsWith("incorrect classpath")); // manager.setStructureModel(AsmManager.getDefault().getHierarchy()); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/OutjarTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/OutjarTest.java index 10c8b3f9d..1d10855e7 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/OutjarTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/ajdt/internal/core/builder/OutjarTest.java @@ -104,9 +104,10 @@ public class OutjarTest extends AjcTestCase { * Expected result = Compile fails with error message. */ public void testOutjarDeletedOnError () { - String[] args = new String[] { "-aspectpath", aspectjarName, "-injars", injarName, "-outjar", outjarName, "-1.4" }; + String[] args = new String[] { "-aspectpath", aspectjarName, "-injars", injarName, "-outjar", outjarName, "-1.8" }; Message error = new Message(WeaverMessages.format(WeaverMessages.CANT_FIND_TYPE_INTERFACES, "jar1.Parent")); - MessageSpec spec = new MessageSpec(null, newMessageList(error)); + Message warning = new Message("advice defined in jar3.Aspect has not been applied [Xlint:adviceDidNotMatch]"); + MessageSpec spec = new MessageSpec(newMessageList(warning), newMessageList(error)); CompilationResult result = ajc(baseDir, args); assertMessages(result, spec); File outjar = new File(ajc.getSandboxDirectory(), outjarName); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java index e8912fead..dfe9d18e8 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTVisitorTest.java @@ -405,9 +405,10 @@ public class ASTVisitorTest extends TestCase { } private void check(String source, String expectedOutput){ - ASTParser parser = ASTParser.newParser(AST.JLS3);//JLS2); // ajh02: need to use 2 for returnType - in 3 it has "returnType2" + // AC: 8-Feb-2025: Trying 20 as the first none deprecated one right now + ASTParser parser = ASTParser.newParser(AST.JLS20);//JLS2); // ajh02: need to use 2 for returnType - in 3 it has "returnType2" Map options = new HashMap<>(); - options.put(CompilerOptions.OPTION_Source, "1.5"); + options.put(CompilerOptions.OPTION_Source, "1.8"); parser.setCompilerOptions(options);//JavaCore.getOptions()); parser.setSource(source.toCharArray()); CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); @@ -422,7 +423,7 @@ public class ASTVisitorTest extends TestCase { private void checkJLS3(String source, String expectedOutput) { ASTParser parser = ASTParser.newParser(AST.JLS3); Map options = new HashMap<>(); - options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); + options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); parser.setCompilerOptions(options); parser.setSource(source.toCharArray()); CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTitdTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTitdTest.java index b27ebc019..34f0bda36 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTitdTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/ASTitdTest.java @@ -46,8 +46,8 @@ public class ASTitdTest extends TestCase { } private void checkNameAndModifiers(String source, String expectedOutput){ - ASTParser parser = ASTParser.newParser(AST.JLS2); // ajh02: need to use 2 for returnType - in 3 it has "returnType2" - parser.setCompilerOptions(new HashMap());//JavaCore.getOptions()); + ASTParser parser = ASTParser.newParser(AST.JLS20); // ajh02: need to use 2 for returnType - in 3 it has "returnType2" + parser.setCompilerOptions(new HashMap<>());//JavaCore.getOptions()); parser.setSource(source.toCharArray()); CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); ITDTestVisitor visitor = new ITDTestVisitor(); diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java index f946b96c5..4c9172995 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTest.java @@ -656,17 +656,17 @@ public class AjASTTest extends AjASTTestCase { * implementation for JLS2 and JLS3) */ public void testGetAndSetReturnTypeJLS2() { - AjAST ajast = createAjAST(AST.JLS2); + AjAST ajast = createAjAST(AST.JLS20); AroundAdviceDeclaration d = ajast.newAroundAdviceDeclaration(); - Type t = d.getReturnType(); + Type t = d.getReturnType2(); assertTrue("by default the return type associated with the" + " AroundAdviceDeclaration should be a PrimitiveType", t instanceof PrimitiveType); assertEquals("by default there should be the PrimitiveType.VOID return " + "type associated with the AroundAdviceDeclaration", PrimitiveType.VOID.toString(), ((PrimitiveType) t).toString()); SimpleType s = ajast.newSimpleType(ajast.newSimpleName("name")); - d.setReturnType(s); + d.setReturnType2(s); assertEquals("there should now be a SimpleType return type associated with" + " the AroundAdviceDeclaration", s, d - .getReturnType()); + .getReturnType2()); } /** @@ -1631,23 +1631,23 @@ public class AjASTTest extends AjASTTestCase { // --------- testing that the source ranges have been set correctly --------- public void testDeclareAnnotationType() { - checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @type: C : @MyAnnotation;}", 43, 33); + checkJLS20("@interface MyAnnotation{}class C{}aspect A{declare @type: C : @MyAnnotation;}", 43, 33); } public void testDeclareAnnotationMethod() { - checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @method:public * C.*(..) : @MyAnnotation;}", 43, 49); + checkJLS20("@interface MyAnnotation{}class C{}aspect A{declare @method:public * C.*(..) : @MyAnnotation;}", 43, 49); } public void testDeclareAnnotationField() { - checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @field: * C+.* : @MyAnnotation;}", 43, 39); + checkJLS20("@interface MyAnnotation{}class C{}aspect A{declare @field: * C+.* : @MyAnnotation;}", 43, 39); } public void testDeclareAnnotationConstructor() { - checkJLS3("@interface MyAnnotation{}class C{}aspect A{declare @constructor: C+.new(..) : @MyAnnotation;}", 43, 49); + checkJLS20("@interface MyAnnotation{}class C{}aspect A{declare @constructor: C+.new(..) : @MyAnnotation;}", 43, 49); } public void testDeclareParents() { - checkJLS3("class A{}class B{}aspect C {declare parents : A extends B;}", 28, 29); + checkJLS20("class A{}class B{}aspect C {declare parents : A extends B;}", 28, 29); } @@ -1660,16 +1660,15 @@ public class AjASTTest extends AjASTTestCase { */ public void testDeclareParentsTypePatternNodeSource() { - checkTypePatternSourceRangesJLS3("class A{}class B{}aspect C {declare parents : A extends B;}", new int[][] {{46, 1} , {56, 1 }}); + checkTypePatternSourceRangesJLS20("class A{}class B{}aspect C {declare parents : A extends B;}", new int[][] {{46, 1} , {56, 1 }}); } public void testDeclareParentsAnySource() { - checkTypePatternSourceRangesJLS3("class A{}class B{}aspect C {declare parents : * extends B;}", new int[][] {{46, 1} , {56, 1 }}); + checkTypePatternSourceRangesJLS20("class A{}class B{}aspect C {declare parents : * extends B;}", new int[][] {{46, 1} , {56, 1 }}); } public void testDeclareParentsAndSource() { - - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "class A{}class B{}class D{}class E{}aspect C {declare parents : A && B && D extends E;}", new int[][] { { 64, 11 },// A && B && D, { 64, 1 }, // A @@ -1681,8 +1680,7 @@ public class AjASTTest extends AjASTTestCase { } public void testDeclareParentsNotSource() { - - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "class A{}class B{}class D{}class E{}aspect C {declare parents : A && !B extends E;}", new int[][] { { 64, 7 },// A && !B { 64, 1 }, // A @@ -1693,7 +1691,7 @@ public class AjASTTest extends AjASTTestCase { } public void testDeclareParentsOrSource() { - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "class A{}class B{}class D{}class E{}aspect C {declare parents : A || B || D extends E;}", new int[][] { { 64, 11 },// A || B || D, { 64, 1 }, // A @@ -1705,7 +1703,7 @@ public class AjASTTest extends AjASTTestCase { } public void testDeclareParentsAnyWithAnnotationSource() { - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "@interface AnnotationT {}class E{}aspect C {declare parents : (@AnnotationT *) extends E;}", new int[][] { { 62, 16 },// (@AnnotationT *) { 87, 1 } // E @@ -1714,7 +1712,7 @@ public class AjASTTest extends AjASTTestCase { } public void testDeclareParentsTypeCategorySource() { - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "class A{}class E{}aspect C {declare parents : A && is(ClassType) extends E;}", new int[][] { { 46, 18 },// A && !is(InnerType) { 46, 1 }, // A @@ -1724,7 +1722,7 @@ public class AjASTTest extends AjASTTestCase { } public void testDeclareParentsTypeCategoryNotSource() { - checkTypePatternSourceRangesJLS3( + checkTypePatternSourceRangesJLS20( "class A{}class E{}aspect C {declare parents : A && !is(InnerType) extends E;}", new int[][] { { 46, 19 },// A && !is(InnerType) { 46, 1 }, // A @@ -1744,37 +1742,37 @@ public class AjASTTest extends AjASTTestCase { // } public void testDeclareParentsTypeCategoryInner() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "class A{class B{}}class E{}aspect C {declare parents : B && is(InnerType) extends E;}", TypeCategoryTypePattern.INNER, "is(InnerType)"); } public void testDeclareParentsTypeCategoryInterface() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "interface B{}interface E{}aspect C {declare parents : B && is(InterfaceType) extends E;}", TypeCategoryTypePattern.INTERFACE, "is(InterfaceType)"); } public void testDeclareParentsTypeCategoryClass() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "class B{}class E{}aspect C {declare parents : B && is(ClassType) extends E;}", TypeCategoryTypePattern.CLASS, "is(ClassType)"); } public void testDeclareParentsTypeCategoryAnnotation() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "@interface B{}class E{}aspect C {declare parents : B && is(AnnotationType) extends E;}", TypeCategoryTypePattern.ANNOTATION, "is(AnnotationType)"); } public void testDeclareParentsTypeCategoryAnonymous() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "class A{B annonymousB = new B() {};}class B{}class E{}aspect C {declare parents : B && is(AnonymousType) extends E;}", TypeCategoryTypePattern.ANONYMOUS, "is(AnonymousType)"); } public void testDeclareParentsTypeCategoryEnum() { - checkCategoryTypePatternJLS3( + checkCategoryTypePatternJLS20( "class B{}class E{}aspect C {declare parents : B && !is(EnumType) extends E;}", TypeCategoryTypePattern.ENUM, "is(EnumType)"); } @@ -1789,19 +1787,19 @@ public class AjASTTest extends AjASTTestCase { public void testDeclareWarning() { - checkJLS3("aspect A {pointcut a();declare warning: a(): \"error\";}", 23, 30); + checkJLS20("aspect A {pointcut a();declare warning: a(): \"error\";}", 23, 30); } public void testDeclareError() { - checkJLS3("aspect A {pointcut a();declare error: a(): \"error\";}", 23, 28); + checkJLS20("aspect A {pointcut a();declare error: a(): \"error\";}", 23, 28); } public void testDeclareSoft() { - checkJLS3("aspect A {pointcut a();declare soft: Exception+: a();}", 23, 29); + checkJLS20("aspect A {pointcut a();declare soft: Exception+: a();}", 23, 29); } public void testDeclarePrecedence() { - checkJLS3("aspect A{}aspect B{declare precedence: B,A;}", 19, 23); + checkJLS20("aspect A{}aspect B{declare precedence: B,A;}", 19, 23); } // --------- tests for bugs ---------- diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java index 5d26c5a37..5a5d9f728 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjASTTestCase.java @@ -26,17 +26,14 @@ import org.aspectj.org.eclipse.jdt.core.SourceRange; public abstract class AjASTTestCase extends TestCase { protected AjAST createAjAST() { - return createAjAST(AST.JLS3); + return createAjAST(AST.JLS20); } protected AjAST createAjAST(int astlevel) { - if (astlevel != AST.JLS2 && astlevel != AST.JLS3) { - fail("need to pass AST.JLS2 or AST.JLS3 as an argument"); - } String source = ""; ASTParser parser = ASTParser.newParser(astlevel); parser.setSource(source.toCharArray()); - parser.setCompilerOptions(new HashMap()); + parser.setCompilerOptions(new HashMap<>()); CompilationUnit cu = (CompilationUnit) parser.createAST(null); AST ast = cu.getAST(); assertTrue("the ast should be an instance of AjAST", @@ -44,9 +41,9 @@ public abstract class AjASTTestCase extends TestCase { return (AjAST) ast; } - protected void checkJLS3(String source, ITypePatternTester tester) { - ASTParser parser = ASTParser.newParser(AST.JLS3); - parser.setCompilerOptions(new HashMap()); + protected void checkJLS20(String source, ITypePatternTester tester) { + ASTParser parser = ASTParser.newParser(AST.JLS20); + parser.setCompilerOptions(new HashMap<>()); parser.setSource(source.toCharArray()); CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); AjASTVisitor visitor = tester.createVisitor(); @@ -54,8 +51,8 @@ public abstract class AjASTTestCase extends TestCase { tester.testCondition(visitor); } - protected void checkJLS3(String source, int start, int length) { - checkJLS3(source, new SourceRangeTester(start, length)); + protected void checkJLS20(String source, int start, int length) { + checkJLS20(source, new SourceRangeTester(start, length)); } /** @@ -65,9 +62,9 @@ public abstract class AjASTTestCase extends TestCase { * @param expectedSourceRanges * of TypePattern nodes encountered while visiting the AST */ - protected void checkTypePatternSourceRangesJLS3(String source, + protected void checkTypePatternSourceRangesJLS20(String source, int[][] expectedSourceRanges) { - checkJLS3(source, + checkJLS20(source, new TypePatternSourceRangeTester(expectedSourceRanges)); } @@ -79,9 +76,9 @@ public abstract class AjASTTestCase extends TestCase { * expected category of a TypeCategoryTypePattern node * encountered in the AST */ - protected void checkCategoryTypePatternJLS3(String source, + protected void checkCategoryTypePatternJLS20(String source, int expectedCategory, String expectedExpression) { - checkJLS3(source, new TypeCategoryTester(expectedCategory, expectedExpression)); + checkJLS20(source, new TypeCategoryTester(expectedCategory, expectedExpression)); } diff --git a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java index bdd36723e..6a50217b4 100644 --- a/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java +++ b/org.aspectj.ajdt.core/src/test/java/org/aspectj/tools/ajc/AjNaiveASTFlattenerTest.java @@ -144,8 +144,8 @@ public class AjNaiveASTFlattenerTest extends TestCase { } private void check(String source, String expectedOutput) { - ASTParser parser = ASTParser.newParser(AST.JLS2); - parser.setCompilerOptions(new HashMap()); + ASTParser parser = ASTParser.newParser(AST.JLS20); + parser.setCompilerOptions(new HashMap<>()); parser.setSource(source.toCharArray()); CompilationUnit cu2 = (CompilationUnit) parser.createAST(null); AjNaiveASTFlattener visitor = new AjNaiveASTFlattener(); diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PerCflow.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PerCflow.java index c719b8b5c..6231d79f5 100644 --- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PerCflow.java +++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/PerCflow.java @@ -104,11 +104,10 @@ public class PerCflow extends PerClause { CrosscuttingMembers xcut = inAspect.crosscuttingMembers; Collection previousCflowEntries = xcut.getCflowEntries(); - Pointcut concreteEntry = entry.concretize(inAspect, inAspect, 0, null); // IntMap - // . - // EMPTY - // ) - // ; + Pointcut concreteEntry = entry.concretize(inAspect, inAspect, 0, null); + if (concreteEntry.getSourceLocation() == null) { + concreteEntry.setLocation(sourceContext, start, end); + } List innerCflowEntries = new ArrayList<>(xcut.getCflowEntries()); innerCflowEntries.removeAll(previousCflowEntries); diff --git a/pom.xml b/pom.xml index 336876b8c..f84252ac7 100644 --- a/pom.xml +++ b/pom.xml @@ -27,8 +27,8 @@ true - 1.9.22 - 9.6 + 1.9.23 + 9.7.1 3.2 1.3.0 1.6.3 diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml index e30000fc0..70a47fe98 100644 --- a/run-all-junit-tests/pom.xml +++ b/run-all-junit-tests/pom.xml @@ -184,6 +184,12 @@ ${project.version} test + + io.github.bmuskalla + scoped-system-properties + 1.1.0 + test + 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 69689b8d9..3da7556e5 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 @@ -253,7 +253,7 @@ public class AjcTask extends MatchingTask { // AspectJ_JDK_Update: Check minimum supported ECJ version, currently 1.3 public static final int JAVA_VERSION_MIN = 3; // AspectJ_JDK_Update: Check maximum supported ECJ version - public static final int JAVA_VERSION_MAX = 22; + public static final int JAVA_VERSION_MAX = 23; static final String[] SOURCE_INPUTS; static final String[] TARGET_INPUTS; 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 58b19117c..5758bcfc7 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 @@ -733,7 +733,7 @@ public class AjcTaskTest extends TestCase { task.setPreserveAllLocals(true); task.setProceedOnError(true); task.setReferenceInfo(true); - task.setSource("1.3"); + task.setSource("1.8"); task.setTarget("1.1"); task.setTime(true); task.setVerbose(true); diff --git a/testing/pom.xml b/testing/pom.xml index aa26d8e6b..c05384f23 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -114,6 +114,13 @@ org.apache.commons commons-digester3 ${commons.digester.version} + + + + asm + asm + + org.aspectj diff --git a/testing/src/test/java/org/aspectj/testing/AjcTest.java b/testing/src/test/java/org/aspectj/testing/AjcTest.java index 8686e87b9..66d1cfd0f 100644 --- a/testing/src/test/java/org/aspectj/testing/AjcTest.java +++ b/testing/src/test/java/org/aspectj/testing/AjcTest.java @@ -11,6 +11,7 @@ package org.aspectj.testing; import java.util.ArrayList; import java.util.List; +import org.aspectj.tools.ajc.Ajc; import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.util.LangUtil; @@ -54,13 +55,17 @@ public class AjcTest { public boolean runTest(AjcTestCase testCase) { if (!canRunOnThisVM()) return false; try { - System.out.println("TEST: " + getTitle()); + if (Ajc.verbose) { + System.out.println("TEST: " + getTitle()); + } for (ITestStep step: testSteps) { step.setBaseDir(getDir()); step.execute(testCase); } } finally { - System.out.println("DONE"); + if (Ajc.verbose) { + System.out.println("DONE"); + } } return true; } diff --git a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java index 8241e3947..74bed2170 100644 --- a/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java +++ b/testing/src/test/java/org/aspectj/testing/harness/bridge/CompilerRun.java @@ -94,31 +94,29 @@ public class CompilerRun implements IAjcRun { * During run, these String are passed as the source and arg files to compile. * The list is set up in setupAjcRun(..), when arg files are prefixed with "@". */ - final List /*String*/ - arguments; + final List arguments; /** * During run, these String are collapsed and passed as the injar option. * The list is set up in setupAjcRun(..). */ - final List /*String*/ - injars; + final List injars; /** * During run, these String are collapsed and passed as the inpath option. * The list is set up in setupAjcRun(..), * which extracts only directories from the files attribute. */ - final List inpaths; + final List inpaths; private CompilerRun(Spec spec) { if (null == spec) { throw new IllegalArgumentException("null spec"); } this.spec = spec; - arguments = new ArrayList(); - injars = new ArrayList(); - inpaths = new ArrayList(); + arguments = new ArrayList<>(); + injars = new ArrayList<>(); + inpaths = new ArrayList<>(); } @@ -132,7 +130,7 @@ public class CompilerRun implements IAjcRun { if (LangUtil.isEmpty(inputs)) { return new String[0]; } - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (String input : inputs) { if (null == input) { continue; @@ -164,7 +162,7 @@ public class CompilerRun implements IAjcRun { } suffixes = temp; } - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (String s : inputs) { String input = s; if (null == input) { @@ -528,7 +526,7 @@ public class CompilerRun implements IAjcRun { boolean handlerResult = false; boolean result = false; boolean commandResult = false; - ArrayList argList = new ArrayList(); + ArrayList argList = new ArrayList<>(); final Spec.TestSetup setupResult = spec.testSetup; try { if (spec.outjar == null) { @@ -728,7 +726,7 @@ public class CompilerRun implements IAjcRun { private static String updateBootclasspathForSourceVersion( String sourceVersion, String compilerName, - List toAdd) { + List toAdd) { if (null == sourceVersion) { return null; } @@ -1627,7 +1625,7 @@ public class CompilerRun implements IAjcRun { Option.FORCE_PREFIXES, false); - Map map = new TreeMap(); + Map map = new TreeMap<>(); map.put(eclipseOption, ReflectionFactory.ECLIPSE); //map.put(BUILDERCOMPILER_OPTION, BUILDER_COMPILER); map.put( @@ -1643,7 +1641,7 @@ public class CompilerRun implements IAjcRun { Collections.unmodifiableSet( compilerOptionToClassname.keySet()); // options not permitted in the harness - List list = new ArrayList(); + List