diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b8fbbf386c..c1bf1b3bf4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: # Check for available Temurin releases on https://adoptium.net/releases.html - java: [ 11, 17, 18 ] + java: [ 11, 17, 19 ] runs-on: ubuntu-latest diff --git a/ajde.core/pom.xml b/ajde.core/pom.xml index eefb3a411c..9de1dd3133 100644 --- a/ajde.core/pom.xml +++ b/ajde.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT ajde.core diff --git a/ajde/pom.xml b/ajde/pom.xml index 51679ae2d7..948492f96d 100644 --- a/ajde/pom.xml +++ b/ajde/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT ajde diff --git a/ajdoc/pom.xml b/ajdoc/pom.xml index 50922a65c4..9ab6304dfd 100644 --- a/ajdoc/pom.xml +++ b/ajdoc/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT ajdoc diff --git a/asm/pom.xml b/asm/pom.xml index ff1bdc1edc..02229d0d0d 100644 --- a/asm/pom.xml +++ b/asm/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT asm diff --git a/aspectjmatcher/pom.xml b/aspectjmatcher/pom.xml index f707b22e61..9f664c0bde 100644 --- a/aspectjmatcher/pom.xml +++ b/aspectjmatcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT aspectjmatcher diff --git a/aspectjrt/pom.xml b/aspectjrt/pom.xml index 22a47dd293..09e67eef04 100644 --- a/aspectjrt/pom.xml +++ b/aspectjrt/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT aspectjrt diff --git a/aspectjtools/pom.xml b/aspectjtools/pom.xml index 3c6f708d35..eb9300e31b 100644 --- a/aspectjtools/pom.xml +++ b/aspectjtools/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT aspectjtools diff --git a/aspectjweaver/pom.xml b/aspectjweaver/pom.xml index a173b769c9..09dfb01a93 100644 --- a/aspectjweaver/pom.xml +++ b/aspectjweaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT aspectjweaver diff --git a/bcel-builder/pom.xml b/bcel-builder/pom.xml index f2f8ca305a..d8eb96943c 100644 --- a/bcel-builder/pom.xml +++ b/bcel-builder/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT bcel-builder diff --git a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java index 6c2240b9de..87c36f2ffe 100644 --- a/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java @@ -100,8 +100,10 @@ public interface Constants { short MINOR_17 = 0; short MAJOR_18 = 62; short MINOR_18 = 0; -// short MAJOR_19 = 63; -// short MINOR_19 = 0; + short MAJOR_19 = 63; + short MINOR_19 = 0; +// short MAJOR_20 = 64; +// short MINOR_20 = 0; int PREVIEW_MINOR_VERSION = 65535; diff --git a/bridge/pom.xml b/bridge/pom.xml index 20411313cb..fcbc63e006 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT bridge diff --git a/build/pom.xml b/build/pom.xml index 23ae6dd979..cb2fb7456f 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT build diff --git a/docs/dist/doc/README-1919.html b/docs/dist/doc/README-1919.html new file mode 100644 index 0000000000..a146c53a7b --- /dev/null +++ b/docs/dist/doc/README-1919.html @@ -0,0 +1,163 @@ + + + + +AspectJ 1.9.19 Readme + + + + +
© Copyright 2022 Contributors. All rights reserved.
+ +

AspectJ 1.9.19

+ +

+ Please note that Bugzilla for issue management is deprecated and new issues should be filed as + GitHub issues. + The list of issues addressed for 1.9.19 can be found here: +

+

+ +

New features

+ +

+ AspectJ 1.9.19 supports Java 19 and its final, preview and + incubator features, such as: +

+ + +Please note that the upstream Eclipse Java Compiler (ECJ) which the AspectJ Compiler (AJC) is a fork of still has some +open issues concerning Java 19 preview feature support, see the list in +this comment. AJC therefore +inherits the same problems for the specific cases described in the linked issues. + +

Improvements

+ +

+ In annotation style aspects, asynchronous proceed() calls in @Around advice now works in threads + created from within the advice. Previously, this was only working in native syntax aspects. There is still a + limitation with regard to asynchronous proceed, if you do not create the thread in the advice but want to use e.g. + an ExecutorService with its own thread pool. This still is not working in annotation style aspects, only in + native syntax ones. +

+

+ See issue #128 and + pull request #132 for more details. +

+

Code examples

+ +

+ You can find some sample code in the AspectJ test suite under the respective AspectJ version in which the features + were first supported (possibly as JVM preview features): +

+ + +

Other changes and bug fixes

+ + + +

AspectJ usage hints

+ +

AspectJ compiler build system requirements

+ +

+ Since 1.9.7, the AspectJ compiler ajc (contained in the aspectjtools library) no longer works on + JDKs 8 to 10. The minimum compile-time requirement is now JDK 11 due to upstream changes in the Eclipse Java Compiler + (subset of JDT Core), which AspectJ is a fork of. You can still compile to legacy target versions as low as Java 1.3 + when compiling plain Java code or using plain Java ITD constructs which do not require the AspectJ runtime + aspectjrt, but the compiler itself needs JDK 11+. Just like in previous AspectJ versions, both the runtime + aspectjrt and the load-time weaver aspectjweaver still only require JRE 8+. +

+ +

Use LTW on Java 16+

+ +

+ Please note that if you want to use load-time weaving on Java 16+, the weaving agent collides with + JEP 396 (Strongly Encapsulate JDK Internals by Default) and related + subsequent JEPs. Therefore, you need to set the JVM parameter --add-opens java.base/java.lang=ALL-UNNAMED in + order to enable aspect weaving. This is due to the fact that the weaver uses internal APIs for which we have not found + an adequate replacement yet when defining classes in different classloaders. +

+ +

Compile with Java preview features

+ +

+ For features marked as preview on a given JDK, you need to compile with ajc --enable-preview and run with + java --enable-preview on that JDK. +

+

+ Please note that you cannot run code compiled with preview features on any other JDK than the one used for + compilation. For example, records compiled with preview on JDK 15 cannot be used on JDK 16 without recompilation. This + is a JVM limitation unrelated to AspectJ. Also, e.g. sealed classes are preview-1 on JDK 15 and preview-2 on JDK 16. + You still need to recompile, no matter what. +

+ +
+ +

+ Available: 1.9.19 on DD-MMM-2022 +

+ + + + diff --git a/docs/dist/doc/index.html b/docs/dist/doc/index.html index 371961da2b..84d4f79ad3 100644 --- a/docs/dist/doc/index.html +++ b/docs/dist/doc/index.html @@ -136,6 +136,8 @@

AspectJ documentation

README's Changes and porting guide for AspectJ + 1.9.19, + 1.9.9 and 1.9.9.1, 1.9.8, 1.9.7, 1.9.6, diff --git a/docs/pom.xml b/docs/pom.xml index 39a7c0f7f0..30c0c2f689 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT docs diff --git a/installer/pom.xml b/installer/pom.xml index 499c48f161..a9474926c5 100644 --- a/installer/pom.xml +++ b/installer/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT installer diff --git a/lib/pom.xml b/lib/pom.xml index 712df99053..eb26770dbe 100644 --- a/lib/pom.xml +++ b/lib/pom.xml @@ -7,7 +7,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT lib diff --git a/loadtime/pom.xml b/loadtime/pom.xml index c940bab301..0a759d23b3 100644 --- a/loadtime/pom.xml +++ b/loadtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT loadtime diff --git a/org.aspectj.ajdt.core/pom.xml b/org.aspectj.ajdt.core/pom.xml index 37b5fb181c..b3a358989f 100644 --- a/org.aspectj.ajdt.core/pom.xml +++ b/org.aspectj.ajdt.core/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT org.aspectj.ajdt.core diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildNotifier.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildNotifier.java index 1a82cb6a01..53fb5750c5 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildNotifier.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildNotifier.java @@ -11,10 +11,11 @@ package org.aspectj.ajdt.internal.core.builder; import org.aspectj.bridge.IProgressListener; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IProgressMonitor; import org.aspectj.org.eclipse.jdt.internal.core.builder.BuildNotifier; +import java.util.function.BooleanSupplier; + /** * @author colyer * @@ -26,8 +27,8 @@ public class AjBuildNotifier extends BuildNotifier implements IProgressListener * @param monitor * @param project */ - public AjBuildNotifier(IProgressMonitor monitor, IProject project) { - super(monitor, project); + public AjBuildNotifier(IProgressMonitor monitor, int buildKind, BooleanSupplier interruptSupplier) { + super(monitor, buildKind, interruptSupplier); } /* (non-Javadoc) diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java index 6435903c8d..f352a76907 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java @@ -16,6 +16,7 @@ import java.util.Locale; import java.util.Map; import java.util.Properties; +import java.util.function.BooleanSupplier; import org.aspectj.ajdt.core.AspectJCore; import org.aspectj.ajdt.internal.compiler.CompilerAdapter; @@ -149,8 +150,8 @@ public ICompilerAdapter getAdapter(Compiler forCompiler) { * @see org.eclipse.jdt.internal.core.builder.JavaBuilder#createBuildNotifier(org.eclipse.core.runtime.IProgressMonitor, * org.eclipse.core.resources.IProject) */ - protected BuildNotifier createBuildNotifier(IProgressMonitor monitor, IProject currentProject) { - return new AjBuildNotifier(monitor, currentProject); + protected BuildNotifier createBuildNotifier(IProgressMonitor monitor, int buildKind, BooleanSupplier interruptSupplier) { + return new AjBuildNotifier(monitor, buildKind, interruptSupplier); } private void initWorldAndWeaver(AjCompilerOptions options) { 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 23bd98c021..d837c76dce 100644 --- a/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties +++ b/org.aspectj.ajdt.core/src/main/resources/org/aspectj/org/eclipse/jdt/internal/compiler/batch/messages_aspectj.properties @@ -1,5 +1,5 @@ compiler.name = AspectJ Compiler -compiler.version = Eclipse Compiler d3a80f1f9b2f8a (21Mar2022) - Java18 +compiler.version = Eclipse Compiler 19f448f47c9e3e (15Dec2022) - Java19 compiler.copyright = misc.version = {0} {1} - {2} {3} diff --git a/org.aspectj.matcher/pom.xml b/org.aspectj.matcher/pom.xml index bc4ac7896d..1af71688be 100644 --- a/org.aspectj.matcher/pom.xml +++ b/org.aspectj.matcher/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT org.aspectj.matcher diff --git a/pom.xml b/pom.xml index 07777058ce..4c4b722413 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT pom AspectJ Parent Project @@ -21,8 +21,8 @@ true - 1.9.9.1 - 9.2 + 1.9.19-SNAPSHOT + 9.4 1.6.3 2.6.2 1.2 diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml index 30df18d382..b636018c2b 100644 --- a/run-all-junit-tests/pom.xml +++ b/run-all-junit-tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT run-all-junit-tests diff --git a/runtime/pom.xml b/runtime/pom.xml index e669549330..1da7e877ef 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT runtime diff --git a/taskdefs/pom.xml b/taskdefs/pom.xml index 55f5436e05..d923446ad7 100644 --- a/taskdefs/pom.xml +++ b/taskdefs/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT taskdefs 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 650fdc4e58..dc83ed7fab 100644 --- a/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -252,15 +252,15 @@ public String toString() { static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18" + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19" }; static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", - "10", "11", "12", "13", "14", "15", "16", "17", "18" + "10", "11", "12", "13", "14", "15", "16", "17", "18", "19" }; static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", - "-10", "-11", "-12", "-13", "-14", "-15", "-16", "-17", "-18" + "-10", "-11", "-12", "-13", "-14", "-15", "-16", "-17", "-18", "-19" }; private static final ICommandEditor COMMAND_EDITOR; diff --git a/testing-client/pom.xml b/testing-client/pom.xml index 864dac12ca..2e2ea723ca 100644 --- a/testing-client/pom.xml +++ b/testing-client/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT testing-client diff --git a/testing-drivers/pom.xml b/testing-drivers/pom.xml index 30b75c3ca9..08c7cf38d6 100644 --- a/testing-drivers/pom.xml +++ b/testing-drivers/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT testing-drivers diff --git a/testing-util/pom.xml b/testing-util/pom.xml index a596d0c99a..a0866689e8 100644 --- a/testing-util/pom.xml +++ b/testing-util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT testing-util diff --git a/testing/pom.xml b/testing/pom.xml index ae7fd0d9a4..a1ff200563 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT testing diff --git a/testing/src/test/java/org/aspectj/testing/OutputSpec.java b/testing/src/test/java/org/aspectj/testing/OutputSpec.java index 5a6594756f..14fc3bb621 100644 --- a/testing/src/test/java/org/aspectj/testing/OutputSpec.java +++ b/testing/src/test/java/org/aspectj/testing/OutputSpec.java @@ -17,6 +17,8 @@ import org.aspectj.tools.ajc.AjcTestCase; import org.aspectj.util.LangUtil; +import static java.lang.Double.parseDouble; + public class OutputSpec { private List expectedOutputLines = new ArrayList<>(); @@ -28,28 +30,31 @@ public void addLine(OutputLine line) { } /** - * For a test output line that has specified a vm version, check if it matches the vm we are running on. - * vm might be "1.2,1.3,1.4,1.5" or simply "9" or it may be a version with a '+' suffix indicating that - * level or later, e.g. "9+" should be ok on Java 10 - * @return true if the current vm version matches the spec + * For a test output line that has specified list of JVM version ranges, determine whether the JVM we are running on + * matches at least one of those ranges. + * + * @param vmVersionRanges might be a single version like "9", a list of versions like "1.2,1.3,1.4,1.5", an equivalent + * range of "1.2-1.5", an open range like "-1.8", "9-" (equivalent to "9+") or a more complex list of ranges + * like "-1.6,9-11,13-14,17-" or "8,11,16+". Empty ranges like in "", " ", "8,,14", ",5", "6-," will be + * ignored. I.e., they will not yield a positive match. Bogus ranges like "9-11-14" will be ignored, too. + * + * @return true if the current vmVersionRanges version matches the spec */ - private boolean matchesThisVm(String vm) { - // vm might be 1.2, 1.3, 1.4, 1.5 or 1.9 possibly with a '+' in there - // For now assume + is attached to there only being one version, like "9+" - // System.out.println("Checking "+vm+" for "+LangUtil.getVmVersionString()); - String v = LangUtil.getVmVersionString(); - if (v.endsWith(".0")) { - v = v.substring(0,v.length()-2); - } - if (vm.contains(v)) { - return true; - } - if (vm.endsWith("+")) { - double vmVersion = LangUtil.getVmVersion(); - double vmSpecified = Double.parseDouble(vm.substring(0,vm.length()-1)); - return vmVersion >= vmSpecified; - } - return false; + private boolean matchesThisVm(String vmVersionRanges) { + double currentVmVersion = LangUtil.getVmVersion(); + return Arrays.stream(vmVersionRanges.split(",")) + .map(String::trim) + .filter(range -> !range.isEmpty()) + .map(range -> range + .replaceFirst("^([0-9.]+)$", "$1-$1") // single version 'n' to range 'n-n' + .replaceFirst("^-", "0-") // left open range '-n' to '0-n' + .replaceFirst("[+-]$", "-99999") // right open range 'n-' or 'n+' to 'n-99999' + .split("-") // range 'n-m' to array ['n', 'm'] + ) + .filter(range -> range.length == 2) + .map(range -> new double[] { parseDouble(range[0]), parseDouble(range[1]) }) + //.filter(range -> { System.out.println(range[0] + " - " +range[1]); return true; }) + .anyMatch(range -> range[0] <= currentVmVersion && range[1] >= currentVmVersion); } public void matchAgainst(String output) { diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java index ba4d006058..fade6c92fe 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v 2.0 @@ -20,14 +20,13 @@ public abstract class XMLBasedAjcTestCaseForJava18Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { // Activate this block after upgrading to JDT Core Java 19 - /* throw new IllegalStateException( "These tests need a Java 18 level AspectJ compiler " + "(e.g. because they use version-specific preview features). " + "This compiler does not support preview features of a previous version anymore." ); - */ // Activate this block before upgrading to JDT Core Java 19 + /* if (!LangUtil.is18VMOrGreater() || LangUtil.is19VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 18 only " + @@ -35,6 +34,7 @@ public void setUp() throws Exception { ); } super.setUp(); + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java index 9b9efdd34b..20e26862f8 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v 2.0 diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19Only.java new file mode 100644 index 0000000000..e0a99283d3 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19Only.java @@ -0,0 +1,40 @@ +/* ******************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava19Only extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + // Activate this block after upgrading to JDT Core Java 20 + /* + throw new IllegalStateException( + "These tests need a Java 19 level AspectJ compiler " + + "(e.g. because they use version-specific preview features). " + + "This compiler does not support preview features of a previous version anymore." + ); + */ + // Activate this block before upgrading to JDT Core Java 20 + if (!LangUtil.is19VMOrGreater() || LangUtil.is20VMOrGreater()) { + throw new IllegalStateException( + "These tests should be run on Java 19 only " + + "(e.g. because they use version-specific preview features)" + ); + } + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19OrLater.java new file mode 100644 index 0000000000..95beffef53 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava19OrLater.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * ******************************************************************/ +package org.aspectj.testing; + +import org.aspectj.util.LangUtil; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Alexander Kriegisch + */ +public abstract class XMLBasedAjcTestCaseForJava19OrLater extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + if (!LangUtil.is19VMOrGreater()) + throw new IllegalStateException("These tests should be run on Java 19 or later"); + super.setUp(); + } + +} diff --git a/tests/features1919/java19/RecordPatternsPreview1Aspect.aj b/tests/features1919/java19/RecordPatternsPreview1Aspect.aj new file mode 100644 index 0000000000..20f6a54e50 --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1Aspect.aj @@ -0,0 +1,35 @@ +public aspect RecordPatternsPreview1Aspect { + public static void main(String[] args) { + doSomething(new Point(2, 7)); + doSomething(new Rectangle( + new ColoredPoint(new Point(1, 6), Color.RED), + new ColoredPoint(new Point(4, 6), Color.BLUE) + )); + } + + public static void doSomething(Object object) { + System.out.println("Doing something with " + object); + } + + before(Object object): execution(* doSomething(*)) && args(object) { + if (object instanceof Point p) { + int x = p.x(); + int y = p.y(); + System.out.println(x + y); + } + if (object instanceof Point(int x, int y)) + System.out.println(x * y); + + if (object instanceof Rectangle(ColoredPoint ul, ColoredPoint lr)) + System.out.println("Upper-left color: " + ul.c()); + if (object instanceof Rectangle(ColoredPoint(Point p, Color c), ColoredPoint lr)) + System.out.println("Upper-left color: " + c); + if (object instanceof Rectangle(ColoredPoint(Point(var x, var y), var c), var lr)) + System.out.println("Upper-left x coordinate: " + x); + } +} + +record Point(int x,int y){} +enum Color { RED, GREEN, BLUE } +record ColoredPoint(Point p, Color c) {} +record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {} diff --git a/tests/features1919/java19/RecordPatternsPreview1Error.java b/tests/features1919/java19/RecordPatternsPreview1Error.java new file mode 100644 index 0000000000..2a5038e898 --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1Error.java @@ -0,0 +1,24 @@ +/** + * This was not working as expected in ECJ after the initial Java 19 merge the JDT Core main line, + * see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450. + */ +public class RecordPatternsPreview1Error { + public static void main(String[] args) { + erroneousTest1(new Box<>("A")); + erroneousTest2(new Box<>("B")); + } + + static void erroneousTest1(Box bo) { + if (bo instanceof Box(var s)) { // Javac error: raw deconstruction patterns are not allowed + System.out.println("I'm a box"); + } + } + + static void erroneousTest2(Box b) { + if (b instanceof Box(var t)) { // Javac error: raw deconstruction patterns are not allowed + System.out.println("I'm a box"); + } + } +} + +record Box(T t) {} diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj new file mode 100644 index 0000000000..44c7f12d0c --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessAspect.aj @@ -0,0 +1,37 @@ +public aspect RecordPatternsPreview1ExhaustivenessAspect { + static Pair p2 = new Pair<>(new C(), new D()); + + public static void main(String[] args) { + doSomething(p2); + } + + public static void doSomething(Pair pair) { + System.out.println(pair.toString().replaceAll("@[0-9a-f]+", "@000")); + } + + before(Pair pair) : execution(* doSomething(Pair)) && args(pair) { + switch (pair) { + case Pair(I i, C c) -> System.out.println("x"); + case Pair(I i, D d) -> System.out.println("y"); + // TODO: Remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // has been fixed. But even with the default clause, it generates wrong byte code and throws runtime error: + // NoSuchMethodError: 'I Pair.x()' + default -> System.out.println("z"); + } + + switch (pair) { + case Pair(C c, I i) -> System.out.println("a"); + case Pair(D d, C c) -> System.out.println("b"); + case Pair(D d1, D d2) -> System.out.println("c"); + // TODO: remove redundant default clause when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // has been fixed. But even with the default clause, it generates wrong byte code and throws runtime error: + // NoSuchMethodError: 'I Pair.x()' + default -> System.out.println("d"); + } + } +} + +sealed interface I permits C, D { } +final class C implements I { } +final class D implements I { } +record Pair(T x, T y) { } diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessError.java b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessError.java new file mode 100644 index 0000000000..8df0794743 --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessError.java @@ -0,0 +1,22 @@ +public class RecordPatternsPreview1ExhaustivenessError { + static Pair p2 = new Pair<>(new C(), new D()); + + public static void main(String[] args) { + exhaustiveSwitch(); + } + + static void exhaustiveSwitch() { + switch (p2) { + case Pair(C fst, D snd) -> System.out.println("a"); + case Pair(D fst, C snd) -> System.out.println("b"); + case Pair(I fst, C snd) -> System.out.println("c"); + } + } +} + +class A { } +class B extends A { } +sealed interface I permits C, D { } +final class C implements I { } +final class D implements I { } +record Pair(T x, T y) { } diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java new file mode 100644 index 0000000000..4153d5021a --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK1.java @@ -0,0 +1,28 @@ +public class RecordPatternsPreview1ExhaustivenessOK1 { + static Pair p1 = new Pair<>(new A(), new B()); + static Pair p2 = new Pair<>(new C(), new D()); + + public static void main(String[] args) { + exhaustiveSwitch(); + } + + static void exhaustiveSwitch() { + switch (p2) { + case Pair(I i, C c) -> System.out.println("x"); + case Pair(I i, D d) -> System.out.println("y"); + } + + switch (p2) { + case Pair(C c, I i) -> System.out.println("a"); + case Pair(D d, C c) -> System.out.println("b"); + case Pair(D d1, D d2) -> System.out.println("c"); + } + } +} + +class A { } +class B extends A { } +sealed interface I permits C, D { } +final class C implements I { } +final class D implements I { } +record Pair(T x, T y) { } diff --git a/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK2.java b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK2.java new file mode 100644 index 0000000000..8f80aad903 --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1ExhaustivenessOK2.java @@ -0,0 +1,10 @@ +public class RecordPatternsPreview1ExhaustivenessOK2 { + public static void main(String[] args) { + Person person = new Person("Bob", 12); + switch (person) { + case Person(var name, var age) -> System.out.println(name + " " + age); + } + } +} + +record Person(String name, int age) { } diff --git a/tests/features1919/java19/RecordPatternsPreview1OK.java b/tests/features1919/java19/RecordPatternsPreview1OK.java new file mode 100644 index 0000000000..ba62f79d5b --- /dev/null +++ b/tests/features1919/java19/RecordPatternsPreview1OK.java @@ -0,0 +1,15 @@ +public class RecordPatternsPreview1OK { + static void printGenericBoxString1(Box objectBox) { + if (objectBox instanceof Box(String s)) { + System.out.println(s); + } + } + + static void printGenericBoxString2(Box stringBox) { + if (stringBox instanceof Box(var s)) { + System.out.println(s); + } + } +} + +record Box(T t) {} diff --git a/tests/features1919/java19/SwitchPatternPreview3Aspect.aj b/tests/features1919/java19/SwitchPatternPreview3Aspect.aj new file mode 100644 index 0000000000..ae147dad7c --- /dev/null +++ b/tests/features1919/java19/SwitchPatternPreview3Aspect.aj @@ -0,0 +1,88 @@ +import java.util.List; +import java.util.Locale; + +aspect SwitchPatternPreview3Aspect { + Object around(Object o) : execution(* doSomethingWithObject(*)) && args(o) { + System.out.println(switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }); + return proceed(o); + } + + before(Shape s) : execution(* doSomethingWithShape(*)) && args(s) { + System.out.println(switch (s) { + case Circle c when (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }); + } + + after(S s) : execution(* doSomethingWithSealedClass(*)) && args(s) { + System.out.println(switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }); + } + + Object around(Integer i): execution(* doSomethingWithInteger(*)) && args(i) { + System.out.println( + switch (i) { + case null -> "value unavailable: " + i; + case -1, 1 -> "absolute value 1: " + i; + case Integer value when value > 0 -> "positive integer: " + i; + default -> "other integer: " + i; + } + ); + return proceed(i); + } +} + +class Shape {} +class Rectangle extends Shape {} +class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } +} + +sealed interface S permits A, B, C {} +final class A implements S {} +final class B implements S {} +record C(int i) implements S {} // Implicitly final + +class Application { + public static void main(String[] args) { + doSomethingWithObject(null); + doSomethingWithObject(123); + doSomethingWithObject(999L); + doSomethingWithObject(12.34); + doSomethingWithObject("foo"); + doSomethingWithObject(List.of(123, "foo", 999L, 12.34)); + + doSomethingWithShape(new Rectangle()); + doSomethingWithShape(new Circle(5)); + doSomethingWithShape(new Circle(6)); + + doSomethingWithSealedClass(new A()); + doSomethingWithSealedClass(new B()); + doSomethingWithSealedClass(new C(5)); + + doSomethingWithInteger(-1); + doSomethingWithInteger(0); + doSomethingWithInteger(42); + doSomethingWithInteger(-99); + doSomethingWithInteger(Integer.valueOf(123)); + doSomethingWithInteger(null); + } + + public static Object doSomethingWithObject(Object o) { return o; } + public static void doSomethingWithSealedClass(S s) {} + public static void doSomethingWithShape(Shape s) {} + public static Object doSomethingWithInteger(Integer o) { return o; } +} diff --git a/tests/features1919/java19/SwitchPatternPreview3Error1.java b/tests/features1919/java19/SwitchPatternPreview3Error1.java new file mode 100644 index 0000000000..5f3895cc32 --- /dev/null +++ b/tests/features1919/java19/SwitchPatternPreview3Error1.java @@ -0,0 +1,13 @@ +/** + * Inspired by examples in https://openjdk.java.net/jeps/420 + */ +public class SwitchPatternPreview3Error1 { + static void constantLabelsMustAppearBeforePatterns1(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + default -> System.out.println("other integer: " + i); + } + } +} diff --git a/tests/features1919/java19/SwitchPatternPreview3Error2.java b/tests/features1919/java19/SwitchPatternPreview3Error2.java new file mode 100644 index 0000000000..c02c4d3cc7 --- /dev/null +++ b/tests/features1919/java19/SwitchPatternPreview3Error2.java @@ -0,0 +1,21 @@ +/** + * Inspired by examples in https://openjdk.java.net/jeps/420 + */ +public class SwitchPatternPreview3Error2 { + static void constantLabelsMustAppearBeforePatterns2(Object o) { + switch (o) { + case null -> System.out.println("value unavailable: " + o); + // This seems to be a bug in JEP 420 implementation. Those constants should be compatible with 'Object'. + // case -1, 1 -> System.out.println("absolute value 1: " + o); + // case "hello" -> System.out.println("string value: " + o); + + // 'Integer value' dominates the next two, more specific ones -> error + case Integer value -> System.out.println("other integer: " + o); + case Integer value when (value == 1 || value == -1) -> System.out.println("absolute value 1: " + o); + case Integer value when value > 0 -> System.out.println("positive integer: " + o); + + case String value when value.startsWith("hello") -> System.out.println("greeting: " + o); + default -> System.out.println("other type: " + o); + } + } +} diff --git a/tests/features1919/java19/SwitchPatternPreview3OK.java b/tests/features1919/java19/SwitchPatternPreview3OK.java new file mode 100644 index 0000000000..7395f08e92 --- /dev/null +++ b/tests/features1919/java19/SwitchPatternPreview3OK.java @@ -0,0 +1,174 @@ +import java.util.List; +import java.util.Locale; + +/** + * Inspired by examples in https://openjdk.org/jeps/427 + */ +public class SwitchPatternPreview3OK { + public static void main(String[] args) { + + System.out.println(formatterPatternSwitch(null)); + System.out.println(formatterPatternSwitch(123)); + System.out.println(formatterPatternSwitch(999L)); + System.out.println(formatterPatternSwitch(12.34)); + System.out.println(formatterPatternSwitch("foo")); + System.out.println(formatterPatternSwitch(List.of(123, "foo", 999L, 12.34))); + + System.out.println(testCircle(new Rectangle())); + System.out.println(testCircle(new Circle(5))); + System.out.println(testCircle(new Circle(6))); + + System.out.println(testSealedCoverage(new A())); + System.out.println(testSealedCoverage(new B())); + System.out.println(testSealedCoverage(new C(5))); + +// constantLabelMustAppearBeforePattern(-1); +// constantLabelMustAppearBeforePattern(0); +// constantLabelMustAppearBeforePattern(42); +// constantLabelMustAppearBeforePattern(-99); +// constantLabelMustAppearBeforePattern(Integer.valueOf(123)); +// constantLabelMustAppearBeforePattern(null); + + constantLabelMustAppearBeforePatternInteger(-1); + constantLabelMustAppearBeforePatternInteger(0); + constantLabelMustAppearBeforePatternInteger(42); + constantLabelMustAppearBeforePatternInteger(-99); + constantLabelMustAppearBeforePatternInteger(Integer.valueOf(123)); + constantLabelMustAppearBeforePatternInteger(null); + +// System.out.println(testGenericSealedExhaustive(new B())); + } + + static String formatterPatternSwitch(Object o) { + return switch (o) { + case null -> "null"; + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format(Locale.ENGLISH, "double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; + } + + static class Shape {} + static class Rectangle extends Shape {} + static class Circle extends Shape { + private final double radius; + public Circle(double radius) { this.radius = radius; } + double calculateArea() { return Math.PI * radius * radius; } + } + + static String testCircle(Shape s) { + return switch (s) { + case Circle c when (c.calculateArea() > 100) -> "Large circle"; + case Circle c -> "Small circle"; + default -> "Non-circle"; + }; + } + + sealed interface S permits A, B, C {} + final static class A implements S {} + final static class B implements S {} + static record C(int i) implements S {} // Implicitly final + + static String testSealedCoverage(S s) { + return switch (s) { + case A a -> "Sealed sub-class A"; + case B b -> "Sealed sub-class B"; + case C c -> "Sealed sub-record C"; + }; + } + + /** + * According to an example from JEP 420, this should work, but it does not, neither with Javac nor ECJ. + * + * See: + * https://openjdk.java.net/jeps/420#1b--Dominance-of-pattern-labels + * https://bugs.openjdk.java.net/browse/JDK-8273326 + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=579355 + * + * TODO: reactivate when implemented or move to preview 3 with Java 19, Eclipse 4.24. + */ + /* + static String constantLabelMustAppearBeforePattern(Object o) { + switch (o) { + case null -> System.out.println("value unavailable: " + i); + case -1, 1 -> System.out.println("special case:" + o); + case Integer i && i > 0 -> System.out.println("positive integer: " + o); + case Integer i -> System.out.println("other integer: " + o); + default -> System.out.println("non-integer: " + o); + } + return i == null ? "null" : i.toString(); + } + */ + + static String constantLabelMustAppearBeforePatternInteger(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + default -> System.out.println("other integer: " + i); + } + return i == null ? "null" : i.toString(); + } + + static void nullCanAppearAfterConstantLabel(Integer i) { + switch (i) { + case -1, 1 -> System.out.println("absolute value 1: " + i); + case null -> System.out.println("value unavailable: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + default -> System.out.println("other integer: " + i); + } + } + + static void defaultCanAppearBeforePattern(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + default -> System.out.println("other integer: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + } + } + + static void defaultCanAppearBeforeNull(Integer i) { + switch (i) { + case -1, 1 -> System.out.println("absolute value 1: " + i); + default -> System.out.println("other integer: " + i); + case null -> System.out.println("value unavailable: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + } + } + + static void defaultCanAppearBeforeConstantLabel(Integer i) { + switch (i) { + case null -> System.out.println("value unavailable: " + i); + default -> System.out.println("other integer: " + i); + case -1, 1 -> System.out.println("absolute value 1: " + i); + case Integer value when value > 0 -> System.out.println("positive integer: " + i); + } + } + + /** + * According to an example from JEP 420, this should work with preview 2 (Java 18), and it does with Javac, + * but not with ECJ for Java 18 and 19. + * + * See: + * https://openjdk.java.net/jeps/420#2--Exhaustiveness-of-switch-expressions-and-statements + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=579360 + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/587 + * + * TODO: reactivate when implemented or move to preview 4 with Java 20. + */ + /* + sealed interface I permits A, B {} + final static class A implements I {} + final static class B implements I {} + + static int testGenericSealedExhaustive(I i) { + return switch (i) { + // Exhaustive as no A case possible! + case B bi -> 42; + }; + } + */ +} diff --git a/tests/features199/java18/SwitchPatternPreview2OK.java b/tests/features199/java18/SwitchPatternPreview2OK.java index b36b26bf23..c17fdc12b5 100644 --- a/tests/features199/java18/SwitchPatternPreview2OK.java +++ b/tests/features199/java18/SwitchPatternPreview2OK.java @@ -90,13 +90,13 @@ static void defaultCanAppearBeforeConstantLabel(Integer i) { } /** - * According to an example from JEP 420, this should work, and it does with Javac, but not with ECJ. + * According to an example from JEP 420, this should work with preview 2 (Java 18), and it does with Javac, + * but not with ECJ for Java 18 and 19. * * See: * https://openjdk.java.net/jeps/420#2--Exhaustiveness-of-switch-expressions-and-statements * https://bugs.eclipse.org/bugs/show_bug.cgi?id=579360 - * - * TODO: reactivate when implemented or move to preview 3 with Java 19, Eclipse 4.24. + * https://github.com/eclipse-jdt/eclipse.jdt.core/issues/587 */ /* sealed interface I permits A, B {} diff --git a/tests/pom.xml b/tests/pom.xml index 7b5e400bdc..d767dcebc3 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT tests diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java index d14bc54cb5..21ad9de901 100644 --- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java +++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java @@ -9,6 +9,7 @@ import org.aspectj.systemtest.ajc190.AllTestsAspectJ190; import org.aspectj.systemtest.ajc191.AllTestsAspectJ191; +import org.aspectj.systemtest.ajc1919.AllTestsAspectJ1919; import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; import org.aspectj.systemtest.ajc193.AllTestsAspectJ193; import org.aspectj.systemtest.ajc195.AllTestsAspectJ195; @@ -38,6 +39,7 @@ public static Test suite() { suite.addTest(AllTestsAspectJ197.suite()); suite.addTest(AllTestsAspectJ198.suite()); suite.addTest(AllTestsAspectJ199.suite()); + suite.addTest(AllTestsAspectJ1919.suite()); suite.addTest(AllTests18.suite()); // $JUnit-END$ return suite; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java new file mode 100644 index 0000000000..5f471490d6 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Ajc1919TestsJava.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc1919TestsJava extends XMLBasedAjcTestCaseForJava19OrLater { + + public void testDummyJava19() { + //runTest("dummy Java 19"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc1919TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java new file mode 100644 index 0000000000..da1a81f976 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/AllTestsAspectJ1919.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.util.LangUtil; + +/** + * @author Alexander Kriegisch + */ +public class AllTestsAspectJ1919 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.19 tests"); + suite.addTest(Bugs1919Tests.suite()); + if (LangUtil.is19VMOrGreater()) { + suite.addTest(SanityTestsJava19.suite()); + suite.addTest(Ajc1919TestsJava.suite()); + } + // Do not run tests using a previous compiler's preview features anymore. They would all fail. + // TODO: Comment out the following block when upgrading JDT Core to Java 20 + if (LangUtil.is19VMOrGreater() && !LangUtil.is20VMOrGreater()) { + suite.addTest(Java19PreviewFeaturesTests.suite()); + } + return suite; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java new file mode 100644 index 0000000000..38441267ef --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Bugs1919Tests.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Alexander Kriegisch + */ +public class Bugs1919Tests extends XMLBasedAjcTestCase { + + public void testDummyBug() { + //runTest("dummy Java 19 bug"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Bugs1919Tests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java new file mode 100644 index 0000000000..b4dc12f39f --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/Java19PreviewFeaturesTests.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19Only; + +/** + * @author Alexander Kriegisch + */ +public class Java19PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava19Only { + + public void testSwitchPatternMatchingPreview3Java() { + runTest("switch pattern matching preview 3 java"); + checkVersion("SwitchPatternPreview3OK", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingPreview3Aspect() { + runTest("switch pattern matching preview 3 aspect"); + checkVersion("SwitchPatternPreview3Aspect", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_19, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); + } + + public void testSwitchPatternMatchingPreview3Error1() { + runTest("switch pattern matching preview 3 error 1"); + } + + public void testSwitchPatternMatchingPreview3Error2() { + runTest("switch pattern matching preview 3 error 2"); + } + + public void testRecordPatternsPreview1OK() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns"); + } + + public void testRecordPatternsPreview1Error() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/450 + runTest("record patterns error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK1() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected' twice, + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + //runTest("record patterns exhaustiveness 1"); + } + + public void testRecordPatternsPreview1Aspect() { + runTest("record patterns aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessAspect() { + // TODO: Remove redundant default clauses in RecordPatternsPreview1Aspect when + // https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed. Furthermore, activate '' + // action for XML test case in order to not just compile but also run the code. + System.out.println("TODO: fully activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 has been fixed"); + runTest("record patterns exhaustiveness aspect"); + } + + public void testRecordPatternsPreview1ExhaustivenessError() { + // See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/455 + runTest("record patterns exhaustiveness error"); + } + + public void testRecordPatternsPreview1ExhaustivenessOK2() { + // Falsely throws 'An enhanced switch statement should be exhaustive; a default label expected', + // see https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 + // TODO: activate when fixed + System.out.println("TODO: activate when https://github.com/eclipse-jdt/eclipse.jdt.core/issues/398 has been fixed"); + //runTest("record patterns exhaustiveness 2"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java19PreviewFeaturesTests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc1919.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java new file mode 100644 index 0000000000..fa2abafe5a --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1919/SanityTestsJava19.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2022 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + *******************************************************************************/ +package org.aspectj.systemtest.ajc1919; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava19OrLater; + +/* + * Some very trivial tests that help verify things are OK. + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -19 option + * to check code generation and modification with that version specified. + * + * @author Alexander Kriegisch + */ +public class SanityTestsJava19 extends XMLBasedAjcTestCaseForJava19OrLater { + + public static final int bytecode_version_for_JDK_level = 63; + + // Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) + public void testSimpleJava_A() { + runTest("simple - a"); + } + + public void testSimpleJava_B() { + runTest("simple - b"); + } + + public void testSimpleCode_C() { + runTest("simple - c"); + } + + public void testSimpleCode_D() { + runTest("simple - d"); + } + + public void testSimpleCode_E() { + runTest("simple - e"); + } + + public void testSimpleCode_F() { + runTest("simple - f"); + } + + public void testSimpleCode_G() { + runTest("simple - g"); + } + + public void testSimpleCode_H() { + runTest("simple - h", true); + } + + public void testSimpleCode_I() { + runTest("simple - i"); + } + + public void testVersionCorrect1() { + runTest("simple - j"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect2() { + runTest("simple - k"); + checkVersion("A", bytecode_version_for_JDK_level, 0); + } + + public void testVersionCorrect4() { + runTest("simple - m"); + // Must be 49.0 when -1.5 is specified + checkVersion("A", 49, 0); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(SanityTestsJava19.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("sanity-tests-19.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java index c2e13b550e..d3cbfb9ab9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc196/AllTestsAspectJ196.java @@ -26,7 +26,7 @@ public static Test suite() { // Do not run tests using a previous compiler's preview features anymore. They would all fail. /* if (LangUtil.is14VMOrGreater() && !LangUtil.is15VMOrGreater()) { - suite.addTest(Ajc196PreviewFeaturesTests.suite()); + suite.addTest(Java14PreviewFeaturesTests.suite()); } */ return suite; diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java index 7040deba42..2b3ad813a0 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ public class Ajc199TestsJava extends XMLBasedAjcTestCaseForJava18OrLater { public void testDummyJava18() { - runTest("dummy Java 18"); + //runTest("dummy Java 18"); } public static Test suite() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java index 9cb01eec8f..6b77073bea 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at @@ -23,9 +23,12 @@ public static Test suite() { suite.addTest(SanityTestsJava18.suite()); suite.addTest(Ajc199TestsJava.suite()); } + // Do not run tests using a previous compiler's preview features anymore. They would all fail. + /* if (LangUtil.is18VMOrGreater() && !LangUtil.is19VMOrGreater()) { suite.addTest(Java18PreviewFeaturesTests.suite()); } + */ return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java index 5b2087ed21..9d1dc6c6d9 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java index dbe6f733af..8afe68946f 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java index d86e11454f..2fd9d2660a 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2021 Contributors + * Copyright (c) 2022 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at @@ -13,7 +13,7 @@ /* * Some very trivial tests that help verify things are OK. - * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -17 option + * These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -18 option * to check code generation and modification with that version specified. * * @author Alexander Kriegisch diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java index 5a3cab221f..52602114ed 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/MultiProjTestCompilerConfiguration.java @@ -67,13 +67,14 @@ public String getClasspath() { for (File dir: allOutputPaths) { sb.append(File.pathSeparator + dir.getAbsolutePath()); } - String cp = sb.toString() + File.pathSeparator + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator - + System.getProperty("sun.boot.class.path") + File.pathSeparator + "../runtime/target/classes" + File.pathSeparator - + this.classPath + File.pathSeparator + System.getProperty("aspectjrt.path") + File.pathSeparator - + "../lib/junit/junit.jar" + "c:/batik/batik-1.6/lib/batik-util.jar;" - + "c:/batik/batik-1.6/lib/batik-awt-util.jar;" + "c:/batik/batik-1.6/lib/batik-dom.jar;" - + "c:/batik/batik-1.6/lib/batik-svggen.jar;" + File.pathSeparator + ".." + File.separator + "lib" + File.separator - + "test" + File.separator + "aspectjrt.jar"; + String cp = sb + File.pathSeparator + + new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator + + System.getProperty("sun.boot.class.path") + File.pathSeparator + + "../runtime/target/classes" + File.pathSeparator + + this.classPath + File.pathSeparator + + System.getProperty("aspectjrt.path") + File.pathSeparator + + "../lib/junit/junit.jar" + File.pathSeparator + + ".." + File.separator + "lib" + File.separator + "test" + File.separator + "aspectjrt.jar"; verifyClasspath(cp); if (LangUtil.is9VMOrGreater()) { cp = LangUtil.getJrtFsFilePath() + File.pathSeparator + cp; diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml index 7963070e0e..63313f6240 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc150/ajc150.xml @@ -2750,8 +2750,8 @@ - - + + @@ -3746,65 +3746,65 @@ - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc151/ajc151.xml index 8d8cd66b84..3588f5950a 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc151/ajc151.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc151/ajc151.xml @@ -4,7 +4,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -53,7 +53,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -92,22 +92,22 @@ - - - - + + + + - + - - - - + + + + @@ -120,23 +120,23 @@ - + - + - - + + - - + + @@ -153,7 +153,7 @@ - + @@ -167,19 +167,19 @@ - + - - + + - - + + - + @@ -191,32 +191,32 @@ - + - - + + - + - + - + - + @@ -227,7 +227,7 @@ - + @@ -239,7 +239,7 @@ - + @@ -248,12 +248,12 @@ - + - + @@ -264,7 +264,7 @@ - + @@ -272,18 +272,18 @@ - + - + - + @@ -292,11 +292,11 @@ - + - + @@ -307,7 +307,7 @@ - + @@ -317,7 +317,7 @@ - + @@ -345,7 +345,7 @@ - + @@ -379,7 +379,7 @@ - + @@ -390,10 +390,10 @@ - + - + @@ -403,8 +403,8 @@ - - + + @@ -415,4 +415,4 @@ - \ No newline at end of file + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc154/ajc154.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc154/ajc154.xml index a0d38cb6cc..8ed8e3ffce 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc154/ajc154.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc154/ajc154.xml @@ -27,8 +27,8 @@ - - + + @@ -40,8 +40,8 @@ - - + + @@ -53,8 +53,8 @@ - - + + @@ -66,8 +66,8 @@ - - + + @@ -80,8 +80,8 @@ - - + + @@ -95,8 +95,8 @@ - - + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml index 9140426333..86e1359792 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1611/newfeatures-tests.xml @@ -19,7 +19,7 @@ - + @@ -34,8 +34,8 @@ - - + + @@ -50,14 +50,14 @@ - + - + @@ -65,7 +65,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -103,18 +103,18 @@ - + - - + + - + @@ -122,7 +122,7 @@ - + @@ -135,5 +135,5 @@ - + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml index 650bdea43a..d7423a194c 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1612/ajc1612.xml @@ -7,7 +7,8 @@ - + + @@ -257,10 +258,10 @@ - - - - + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc169/intertype.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc169/intertype.xml index 185e3084c4..e4dbec2fa4 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc169/intertype.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc169/intertype.xml @@ -1,7 +1,7 @@ - + @@ -11,7 +11,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -37,7 +37,7 @@ - + @@ -46,7 +46,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -64,91 +64,98 @@ - + - - - + + + + - + - - - + + + + - + - - - + + + + - + - - - + + + + - + - - - + + + + - + - - - + + + + - + - - - + + + + - + @@ -157,12 +164,12 @@ - + - + @@ -172,7 +179,7 @@ - + @@ -180,17 +187,17 @@ - + - + - + @@ -198,7 +205,7 @@ - + @@ -206,7 +213,7 @@ - + @@ -214,43 +221,43 @@ - + - + - + - + - - - - \ No newline at end of file + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml index f3f18f6d95..5fe1c9ffa7 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc170/ajc170.xml @@ -182,16 +182,16 @@ - - - - - - + + + + + + - - + + @@ -202,16 +202,16 @@ - - + + - - + + - - + + @@ -223,8 +223,8 @@ - - + + @@ -235,8 +235,8 @@ - - + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc173/ajc173.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc173/ajc173.xml index 398fae62fb..a60fca98cf 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc173/ajc173.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc173/ajc173.xml @@ -5,40 +5,40 @@ - + - - + + - + - + - + - + - + - + - + @@ -49,7 +49,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -74,13 +74,13 @@ - + - - @@ -69,7 +69,7 @@ - + @@ -85,26 +85,26 @@ - + - - - + + - + @@ -116,7 +116,7 @@ - + @@ -134,7 +134,7 @@ - + @@ -153,7 +153,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -190,7 +190,7 @@ - + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml index 187fb50b32..8aa734e3e7 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml @@ -8,10 +8,11 @@ - + + - + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190_from150.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190_from150.xml index 885a0b74e7..dede00f0a3 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190_from150.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc190/ajc190_from150.xml @@ -2750,8 +2750,8 @@ - - + + @@ -3746,65 +3746,65 @@ - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml new file mode 100644 index 0000000000..3741b338c6 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/ajc1919.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml new file mode 100644 index 0000000000..25df39e535 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1919/sanity-tests-19.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml index 7c38db68e5..5488671f55 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml @@ -3,10 +3,6 @@ - - - - diff --git a/util/pom.xml b/util/pom.xml index ca3e31e75e..0866d18e38 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT util diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index d916002b69..7151c092b4 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -57,6 +57,8 @@ public static double getVmVersion() { static { // http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html // http://openjdk.java.net/jeps/223 "New Version-String Scheme" + // TODO: Use java.lang.Runtime class (since Java 9, now AspectJ needs Java 11+ due to JDT Core anyway) + final String JAVA_VERSION_NOT_FOUND = "System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version"; try { String vm = System.getProperty("java.version"); // JLS 20.18.7 if (vm == null) { @@ -66,15 +68,12 @@ public static double getVmVersion() { vm = System.getProperty("java.vm.version"); } if (vm == null) { - new RuntimeException( - "System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version") - .printStackTrace(System.err); + new RuntimeException(JAVA_VERSION_NOT_FOUND).printStackTrace(System.err); vmVersion = 1.5; } else { - // Version: [1-9][0-9]*((\.0)*\.[1-9][0-9]*)* // Care about the first set of digits and second set if first digit is 1 try { - List numbers = getFirstNumbers(vm); + List numbers = getJavaMajorMinor(vm); if (numbers.get(0) == 1) { // Old school for 1.0 > 1.8 vmVersion = numbers.get(0)+(numbers.get(1)/10d); @@ -89,16 +88,15 @@ public static double getVmVersion() { } } } catch (Throwable t) { - new RuntimeException( - "System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version", t) - .printStackTrace(System.err); + new RuntimeException(JAVA_VERSION_NOT_FOUND, t).printStackTrace(System.err); vmVersion = 1.5; } } - private static List getFirstNumbers(String vm) { + private static List getJavaMajorMinor(String vm) { List result = new ArrayList<>(); - StringTokenizer st = new StringTokenizer(vm,".-_"); + // Can be something like '1.5', '11.0.16.1', '19+36-2238' + StringTokenizer st = new StringTokenizer(vm.replaceFirst("[+].*", ""), ".-_"); try { result.add(Integer.parseInt(st.nextToken())); result.add(Integer.parseInt(st.nextToken())); @@ -106,6 +104,9 @@ private static List getFirstNumbers(String vm) { // NoSuchElementException if no more tokens // NumberFormatException if not a number } + // Always add a default minor, just in case a caller expects it + if (result.size() == 1) + result.add(0); return result; } @@ -182,6 +183,10 @@ public static boolean is19VMOrGreater() { return 19 <= vmVersion; } + public static boolean is20VMOrGreater() { + return 20 <= vmVersion; + } + /** * Shorthand for "if null, throw IllegalArgumentException" * diff --git a/weaver/pom.xml b/weaver/pom.xml index 966f6791a1..d6e8393136 100644 --- a/weaver/pom.xml +++ b/weaver/pom.xml @@ -6,7 +6,7 @@ org.aspectj aspectj-parent - 1.9.10-SNAPSHOT + 1.9.19-SNAPSHOT weaver