diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-21 10:45:00 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-21 10:51:35 +0700 |
commit | 6dc09db0ca1589f8c53c4dca054e3a852eaaecba (patch) | |
tree | 9c480f1ab92b26d141a249513d89942b1a1e6b73 | |
parent | d3a06a6942b6f69ce9b5b4403d3c1cf1803cf01e (diff) | |
download | aspectj-6dc09db0ca1589f8c53c4dca054e3a852eaaecba.tar.gz aspectj-6dc09db0ca1589f8c53c4dca054e3a852eaaecba.zip |
Prepare code, tests and docs for Java 18
- JDT Core dependency in pom.xml
- Constants.java
- LangUtil.java
- AjcTask.java
- messages_aspectj.properties
- XMLBasedAjcTestCaseForJava17Only.java
- XMLBasedAjcTestCaseForJava18*.java
- tests/bugs199
- tests/features199
- JavaVersionCompatibility.md
- README-199.html
- GitHub CI build
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
32 files changed, 869 insertions, 143 deletions
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9160a83b1..3e2564c77 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - java: [ 11, 17 ] + java: [ 11, 17, 18-ea ] runs-on: ubuntu-latest 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 1ce3682d3..3c1c12daf 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 @@ -98,8 +98,10 @@ public interface Constants { short MINOR_16 = 0; short MAJOR_17 = 61; short MINOR_17 = 0; -// short MAJOR_18 = 62; -// short MINOR_18 = 0; + short MAJOR_18 = 62; + short MINOR_18 = 0; +// short MAJOR_19 = 63; +// short MINOR_19 = 0; int PREVIEW_MINOR_VERSION = 65535; diff --git a/docs/dist/doc/JavaVersionCompatibility.md b/docs/dist/doc/JavaVersionCompatibility.md index be557d462..18a7dcae7 100644 --- a/docs/dist/doc/JavaVersionCompatibility.md +++ b/docs/dist/doc/JavaVersionCompatibility.md @@ -7,6 +7,7 @@ be easily concluded from the AspectJ version number anymore, and we are sorry fo AspectJ version | Java version | Comments ----------------|--------------|-------- +1.9.9 | 18 1.9.8 | 17 | AspectJ compiler requires JDK 11+ during build time. During runtime, AspectJ still only requires Java 8+ for both compile-time and load-time weaving. Pure Java code can be compiled down to as old as 1.3 byte code level. 1.9.7 | 15, 16 1.9.6 | 14 diff --git a/docs/dist/doc/README-198.html b/docs/dist/doc/README-198.html index 5beb81e3d..6b79b5ab9 100644 --- a/docs/dist/doc/README-198.html +++ b/docs/dist/doc/README-198.html @@ -73,7 +73,8 @@ Cross-compilation to legacy JDK </a>: An example class which only works correctly on JDK 8 when compiled with <tt>--release 8</tt> due to API changes in - the JDK. Simply <tt>-source 8 -target 8</tt> would not be enough in this case.</li> + the JDK. Simply <tt>-source 8 -target 8</tt> would not be enough in this case. + </li> <li> <a href="https://github.com/eclipse/org.aspectj/tree/master/tests/features198/java17"> Pattern matching for switch @@ -110,12 +111,6 @@ craft a condy class with ASM</a>. </li> <li> - Improvements for <tt>if()</tt> pointcuts in annotation syntax, see issues - <a href="https://github.com/eclipse/org.aspectj/issues/115">#115</a>, - <a href="https://github.com/eclipse/org.aspectj/issues/120">#120</a>, - <a href="https://github.com/eclipse/org.aspectj/issues/122">#122</a>. - </li> - <li> Thanks to Andrey Turbanov for several clean code contributions and to Dmitry Mikhaylov for fixing a potential concurrency problem. </li> diff --git a/docs/dist/doc/README-199.html b/docs/dist/doc/README-199.html new file mode 100644 index 000000000..8e09cd918 --- /dev/null +++ b/docs/dist/doc/README-199.html @@ -0,0 +1,126 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> + +<head> +<title>AspectJ 1.9.9 Readme</title> +<style type="text/css"> + <!-- + P { margin-left: 20px; } + PRE { margin-left: 20px; } + LI { margin-left: 20px; } + H4 { margin-left: 20px; } + H3 { margin-left: 10px; } + --> +</style> +</head> + +<body> +<div align="right"><small>© Copyright 2022 Contributors. All rights reserved.</small></div> + +<h1>AspectJ 1.9.9</h1> + +<p> + Please note that Bugzilla for issue management is deprecated and new issues should be filed as + <a href="https://github.com/eclipse/org.aspectj/issues/new">GitHub issues</a>. + The list of issues addressed for 1.9.9 can be found + <a href="https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&f0=OP&f1=OP&f3=CP&f4=CP&j1=OR&list_id=16866879&product=AspectJ&query_format=advanced&target_milestone=1.9.9">here for Bugzilla</a> + and <a href="https://github.com/eclipse/org.aspectj/issues?q=is%3Aissue+is%3Aclosed++milestone%3A1.9.9">here for GitHub issues</a>. +</p> + +<h2>New features</h2> + +<p> + AspectJ 1.9.9 supports <a href="https://openjdk.java.net/projects/jdk/18/">Java 18</a> and its final and preview + features, such as: +</p> +<ul> + <li>Pattern matching for <tt>switch</tt> (preview 2)</li> +</ul> + +<h2>Improvements</h2> + +<h2>Code examples</h2> + +<p> + 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): +</p> +<ul> + <li> + <a href="https://github.com/eclipse/org.aspectj/tree/master/tests/features198/java17"> + Pattern matching for switch, preview 1 + </a> + </li> + <li> + <a href="https://github.com/eclipse/org.aspectj/tree/master/tests/features199/java18"> + Pattern matching for switch, preview 2 + </a> + </li> +</ul> + +<h2>Other changes and bug fixes</h2> + +<ul> + <li> + Fix a bug which led to <tt>NullPointerException</tt>s if too many JAR archives were on the classpath. Too many here + means the value system property <tt>org.aspectj.weaver.openarchives</tt> (1,000 by default). The AspectJ compiler is + meant to close archives upon cache exhaustion and then re-open them if it needs them again later. Re-opening was + broken, now the compiler works reliably even for cache sizes as small as 20. See issue + <a href="https://github.com/eclipse/org.aspectj/issues/125">#125</a>. + </li> + <li> + Improvements for <tt>if()</tt> pointcuts in annotation syntax, see issues + <a href="https://github.com/eclipse/org.aspectj/issues/115">#115</a>, + <a href="https://github.com/eclipse/org.aspectj/issues/120">#120</a>, + <a href="https://github.com/eclipse/org.aspectj/issues/122">#122</a>. + </li> + <li> + Thanks to Andrey Turbanov for several clean code contributions. + </li> +</ul> + +<h2>AspectJ usage hints</h2> + +<h3>AspectJ compiler build system requirements</h3> + +<p> + Since 1.9.7, the AspectJ compiler <tt>ajc</tt> (contained in the <tt>aspectjtools</tt> 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 + <tt>aspectjrt</tt>, but the compiler itself needs JDK 11+. Just like in previous AspectJ versions, both the runtime + <tt>aspectjrt</tt> and the load-time weaver <tt>aspectjweaver</tt> still only require JRE 8+. +</p> + +<h3>Use LTW on Java 16+</h3> + +<p> + Please note that if you want to use load-time weaving on Java 16+, the weaving agent collides with + <a href="https://openjdk.java.net/jeps/396">JEP 396 (Strongly Encapsulate JDK Internals by Default)</a> and related + subsequent JEPs. Therefore, you need to set the JVM parameter <tt>--add-opens java.base/java.lang=ALL-UNNAMED</tt> 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. +</p> + +<h3>Compile with Java preview features</h3> + +<p> + For features marked as preview on a given JDK, you need to compile with <tt>ajc --enable-preview</tt> and run with + <tt>java --enable-preview</tt> on that JDK. +</p> +<p> + 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. +</p> + +<hr> + +<p> + <b>Available:</b> 1.9.9 available DD-MMM-2022 +</p> + +</body> + +</html> 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 a54d7ec22..153469df0 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 f8768b6899a6a2 (15Sep2021) - Java17 +compiler.version = Eclipse Compiler a721c849b3f9d5 (18Mar2022) - Java18 compiler.copyright = misc.version = {0} {1} - {2} {3} @@ -21,7 +21,7 @@ <maven.javadoc.skip>true</maven.javadoc.skip> <!-- Dependency versions --> - <jdt.core.version>1.9.9-SNAPSHOT</jdt.core.version> + <jdt.core.version>1.9.9.j18-SNAPSHOT</jdt.core.version> <asm.version>9.2</asm.version> <lib.ant.version>1.6.3</lib.ant.version> <lib.ant.xerces.version>2.6.2</lib.ant.xerces.version> 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 e49580dbe..260d16d90 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 @@ -250,9 +250,18 @@ public class AjcTask extends MatchingTask { public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR"; - 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" }; - 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" }; - 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" }; + 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" + }; + 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" + }; + 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" + }; private static final ICommandEditor COMMAND_EDITOR; diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java index 0c351c69a..78941fcab 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java @@ -20,21 +20,21 @@ public abstract class XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCa @Override public void setUp() throws Exception { // Activate this block after upgrading to JDT Core Java 18 - /* throw new IllegalStateException( "These tests need a Java 17 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 18 + /* if (!LangUtil.is17VMOrGreater() || LangUtil.is18VMOrGreater()) { throw new IllegalStateException( "These tests should be run on Java 17 only " + "(e.g. because they use version-specific preview features)" ); - } super.setUp(); + } + */ } } diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java new file mode 100644 index 000000000..ba4d00605 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18Only.java @@ -0,0 +1,40 @@ +/* ******************************************************************* + * Copyright (c) 2021 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 XMLBasedAjcTestCaseForJava18Only extends XMLBasedAjcTestCase { + + @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 " + + "(e.g. because they use version-specific preview features)" + ); + } + super.setUp(); + } + +} diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java new file mode 100644 index 000000000..9b9efdd34 --- /dev/null +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava18OrLater.java @@ -0,0 +1,27 @@ +/* ******************************************************************* + * Copyright (c) 2021 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 XMLBasedAjcTestCaseForJava18OrLater extends XMLBasedAjcTestCase { + + @Override + public void setUp() throws Exception { + if (!LangUtil.is18VMOrGreater()) + throw new IllegalStateException("These tests should be run on Java 18 or later"); + super.setUp(); + } + +} diff --git a/tests/bugs198/github_115/A.java b/tests/bugs199/github_115/A.java index 07df21f10..07df21f10 100644 --- a/tests/bugs198/github_115/A.java +++ b/tests/bugs199/github_115/A.java diff --git a/tests/bugs198/github_115/B.java b/tests/bugs199/github_115/B.java index eba199b67..eba199b67 100644 --- a/tests/bugs198/github_115/B.java +++ b/tests/bugs199/github_115/B.java diff --git a/tests/bugs198/github_120/C.java b/tests/bugs199/github_120/C.java index 4af57af24..4af57af24 100644 --- a/tests/bugs198/github_120/C.java +++ b/tests/bugs199/github_120/C.java diff --git a/tests/bugs198/github_120/D.java b/tests/bugs199/github_120/D.java index 2ecdaa574..2ecdaa574 100644 --- a/tests/bugs198/github_120/D.java +++ b/tests/bugs199/github_120/D.java diff --git a/tests/bugs198/github_122/E.java b/tests/bugs199/github_122/E.java index 29c818285..29c818285 100644 --- a/tests/bugs198/github_122/E.java +++ b/tests/bugs199/github_122/E.java diff --git a/tests/bugs198/github_125/Application.java b/tests/bugs199/github_125/Application.java index 7e893fc1a..7e893fc1a 100644 --- a/tests/bugs198/github_125/Application.java +++ b/tests/bugs199/github_125/Application.java diff --git a/tests/features199/java18/SwitchPatternPreview2Aspect.aj b/tests/features199/java18/SwitchPatternPreview2Aspect.aj new file mode 100644 index 000000000..ee5dbbd68 --- /dev/null +++ b/tests/features199/java18/SwitchPatternPreview2Aspect.aj @@ -0,0 +1,28 @@ +import java.util.Locale; + +aspect SwitchPatternPreview2Aspect { + Object around(Object o): execution(* doSomethingWithObject(*)) && args(o) { + System.out.println( + switch (o) { + case -1, 1 -> "special case:" + o; + case Integer i && i > 0 -> "positive integer: " + o; + case Integer i -> "other integer: " + o; + default -> "non-integer: " + o; + } + ); + return proceed(o); + } +} + +class Application { + public static void main(String[] args) { + doSomethingWithObject(-1); + doSomethingWithObject(0); + doSomethingWithObject(42); + doSomethingWithObject(-99); + doSomethingWithObject("test"); + doSomethingWithObject(null); + } + + public static Object doSomethingWithObject(Object o) { return o; } +} diff --git a/tests/features199/java18/SwitchPatternPreview2Error.java b/tests/features199/java18/SwitchPatternPreview2Error.java new file mode 100644 index 000000000..b1652aad3 --- /dev/null +++ b/tests/features199/java18/SwitchPatternPreview2Error.java @@ -0,0 +1,31 @@ +/** + * Inspired by examples in https://openjdk.java.net/jeps/420 + */ +public class SwitchPatternPreview2Error { + static void constantLabelMustAppearBeforePattern1(Object o) { + switch (o) { + case Integer i && i > 0 -> System.out.println("positive integer: " + o); + case -1, 1 -> System.out.println("special case:" + o); + case Integer i -> System.out.println("other integer: " + o); + default -> System.out.println("non-integer: " + o); + } + } + + static void constantLabelMustAppearBeforePattern2(Object o) { + switch (o) { + case -1, 1 -> System.out.println("special case:" + o); + case Integer i -> System.out.println("other integer: " + o); + case Integer i && i > 0 -> System.out.println("positive integer: " + o); + default -> System.out.println("non-integer: " + o); + } + } + + static void constantLabelMustAppearBeforePattern3(Object o) { + switch (o) { + case Integer i && i > 0 -> System.out.println("positive integer: " + o); + case Integer i -> System.out.println("other integer: " + o); + case -1, 1 -> System.out.println("special case:" + o); + default -> System.out.println("non-integer: " + o); + } + } +} diff --git a/tests/features199/java18/SwitchPatternPreview2OK.java b/tests/features199/java18/SwitchPatternPreview2OK.java new file mode 100644 index 000000000..859583b6d --- /dev/null +++ b/tests/features199/java18/SwitchPatternPreview2OK.java @@ -0,0 +1,38 @@ +import java.util.List; + +/** + * Inspired by examples in https://openjdk.java.net/jeps/420 + */ +public class SwitchPatternPreview2OK { + public static void main(String[] args) { + constantLabelMustAppearBeforePattern(-1); + constantLabelMustAppearBeforePattern(0); + constantLabelMustAppearBeforePattern(42); + constantLabelMustAppearBeforePattern(-99); + constantLabelMustAppearBeforePattern(Integer.valueOf(123)); + constantLabelMustAppearBeforePattern(null); + + System.out.println(testGenericSealedExhaustive(new B<Integer>())); + } + + static String constantLabelMustAppearBeforePattern(Object o) { + switch (o) { + 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 o.toString(); + } + + sealed interface I<T> permits A, B {} + final static class A<X> implements I<String> {} + final static class B<Y> implements I<Y> {} + + static int testGenericSealedExhaustive(I<Integer> i) { + return switch (i) { + // Exhaustive as no A case possible! + case B<Integer> bi -> 42; + }; + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java index ef597c8f1..3e6ead467 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java @@ -17,35 +17,29 @@ import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater; */ public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater { - public void testSealedClassWithLegalSubclasses() { - runTest("sealed class with legal subclasses"); - // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA - // build, but final JDK version - checkVersion("Employee", Constants.MAJOR_17, 0 /* Constants.PREVIEW_MINOR_VERSION */); - checkVersion("Manager", Constants.MAJOR_17, 0 /* Constants.PREVIEW_MINOR_VERSION */); - } - - public void testSealedClassWithIllegalSubclass() { - runTest("sealed class with illegal subclass"); - // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA - // build, but final JDK version - checkVersion("Person", Constants.MAJOR_17, 0 /* Constants.PREVIEW_MINOR_VERSION */); - } - - public void testWeaveSealedClass() { - runTest("weave sealed class"); - // TODO: replace 0 by Constants.PREVIEW_MINOR_VERSION after no longer using EA - // build, but final JDK version - checkVersion("PersonAspect", Constants.MAJOR_17, 0 /* Constants.PREVIEW_MINOR_VERSION */); - } - - public static Test suite() { - return XMLBasedAjcTestCase.loadSuite(Ajc198TestsJava.class); - } - - @Override - protected java.net.URL getSpecFile() { - return getClassResource("ajc198.xml"); - } + public void testSealedClassWithLegalSubclasses() { + runTest("sealed class with legal subclasses"); + checkVersion("Employee", Constants.MAJOR_17, Constants.MINOR_17); + checkVersion("Manager", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testSealedClassWithIllegalSubclass() { + runTest("sealed class with illegal subclass"); + checkVersion("Person", Constants.MAJOR_17, Constants.MINOR_17); + } + + public void testWeaveSealedClass() { + runTest("weave sealed class"); + checkVersion("PersonAspect", Constants.MAJOR_17, Constants.MINOR_17); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc198TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc198.xml"); + } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java index 3cfc7a149..929b5749d 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java @@ -29,9 +29,12 @@ public class AllTestsAspectJ198 { suite.addTest(SanityTestsJava17.suite()); suite.addTest(Ajc198TestsJava.suite()); } + // Do not run tests using a previous compiler's preview features anymore. They would all fail. + /* if (LangUtil.is17VMOrGreater() && !LangUtil.is18VMOrGreater()) { suite.addTest(Java17PreviewFeaturesTests.suite()); } + */ return suite; } } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Tests.java index 7982ec630..cb3b781bb 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Tests.java @@ -21,33 +21,6 @@ public class Bugs198Tests extends XMLBasedAjcTestCase { runTest("ITD annotation with mandatory parameter via aspectpath"); } - public void testAnnotationStyleSpecialIfClauses() { - runTest("annotation style A"); - } - - public void testAnnotationStylePointcutInheritanceWithIfClauses() { - runTest("annotation style B"); - } - - public void testAnnotationStyleSpecialIfClauses2_gh120() { - runTest("annotation style C"); - } - - public void testAnnotationStyleSpecialIfClauses3_gh120() { - runTest("annotation style D"); - } - - public void testAnnotationStyleNegatedIf_gh122() { - runTest("annotation style negated if"); - } - - public void testGitHub_125() { - try (PropertyEnvironment env = ScopedSystemProperties.newPropertyEnvironment()) { - env.setProperty("org.aspectj.weaver.openarchives", "20"); - runTest("compiler can re-open closed JARs"); - } - } - public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Bugs198Tests.class); } diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java new file mode 100644 index 000000000..7040deba4 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc199; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater; + +/** + * @author Alexander Kriegisch + */ +public class Ajc199TestsJava extends XMLBasedAjcTestCaseForJava18OrLater { + + public void testDummyJava18() { + runTest("dummy Java 18"); + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc199TestsJava.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc199.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java new file mode 100644 index 000000000..9cb01eec8 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc199; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.aspectj.util.LangUtil; + +/** + * @author Alexander Kriegisch + */ +public class AllTestsAspectJ199 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.9 tests"); + suite.addTest(Bugs199Tests.suite()); + if (LangUtil.is18VMOrGreater()) { + suite.addTest(SanityTestsJava18.suite()); + suite.addTest(Ajc199TestsJava.suite()); + } + 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 new file mode 100644 index 000000000..f72f3c44c --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc199; + +import io.bmuskalla.system.properties.PropertyEnvironment; +import io.bmuskalla.system.properties.ScopedSystemProperties; +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; + +/** + * @author Alexander Kriegisch + */ +public class Bugs199Tests extends XMLBasedAjcTestCase { + + public void testAnnotationStyleSpecialIfClauses() { + runTest("annotation style A"); + } + + public void testAnnotationStylePointcutInheritanceWithIfClauses() { + runTest("annotation style B"); + } + + public void testAnnotationStyleSpecialIfClauses2_gh120() { + runTest("annotation style C"); + } + + public void testAnnotationStyleSpecialIfClauses3_gh120() { + runTest("annotation style D"); + } + + public void testAnnotationStyleNegatedIf_gh122() { + runTest("annotation style negated if"); + } + + public void testGitHub_125() { + try (PropertyEnvironment env = ScopedSystemProperties.newPropertyEnvironment()) { + env.setProperty("org.aspectj.weaver.openarchives", "20"); + runTest("compiler can re-open closed JARs"); + } + } + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Bugs199Tests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc199.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java new file mode 100644 index 000000000..8d586b440 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc199; + +import junit.framework.Test; +import org.aspectj.apache.bcel.Constants; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava18Only; + +/** + * @author Alexander Kriegisch + */ +public class Java18PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava18Only { + + public void testSwitchPatternMatchingCaseLabelDominatedByPrecedingError() { + runTest("switch pattern matching error"); + } + + public void testSwitchPatternMatchingJava() { + runTest("switch pattern matching java"); + checkVersion("SwitchPatternOK", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingAspect() { + runTest("switch pattern matching aspect"); + checkVersion("SwitchPatternAspect", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + } + + // TODO: + // JDT Core does not seem to have implemented JEP 420 yet, + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=576746. + // Therefore, deactivate the special tests for now. +/* + public void testSwitchPatternMatchingPreview2Error() { + runTest("switch pattern matching preview 2 error"); + } + + public void testSwitchPatternMatchingPreview2Java() { + runTest("switch pattern matching preview 2 java"); + checkVersion("SwitchPatternOK", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + } + + public void testSwitchPatternMatchingPreview2Aspect() { + runTest("switch pattern matching preview 2 aspect"); + checkVersion("SwitchPatternAspect", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Application", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("Shape", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + checkVersion("S", Constants.MAJOR_18, Constants.PREVIEW_MINOR_VERSION); + } +*/ + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Java18PreviewFeaturesTests.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("ajc199.xml"); + } + +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java new file mode 100644 index 000000000..d86e11454 --- /dev/null +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2021 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.ajc199; + +import junit.framework.Test; +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava18OrLater; + +/* + * 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 + * to check code generation and modification with that version specified. + * + * @author Alexander Kriegisch + */ +public class SanityTestsJava18 extends XMLBasedAjcTestCaseForJava18OrLater { + + public static final int bytecode_version_for_JDK_level = 62; + + // 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(SanityTestsJava18.class); + } + + @Override + protected java.net.URL getSpecFile() { + return getClassResource("sanity-tests-18.xml"); + } + +} diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml index 0eb413baa..85bd872b3 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml @@ -95,76 +95,9 @@ </run> </ajc-test> - <!-- Javac/ECJ 9+ compiler option, but belated implementation in AJC 1.9.7 --> + <!-- Javac/ECJ 9+ compiler option, but belated implementation in AJC 1.9.8 --> <ajc-test dir="features198/compiler_release" vm="9" title="compile to older JDK release"> <compile files="Buffers.java" options="--release 8"/> </ajc-test> - <ajc-test dir="bugs198/github_115" title="annotation style A"> - <compile files="A.java" options="-1.5"> - <message kind="warning" line="28" text="advice defined in Azpect has not been applied [Xlint:adviceDidNotMatch]"/> - </compile> - <run class="A"> - <stdout> - <line text="Azpect.before"/> - <line text="A.main"/> - </stdout> - </run> - </ajc-test> - - <ajc-test dir="bugs198/github_115" title="annotation style B"> - <compile files="B.java" options="-1.5"/> - <run class="B"> - <stdout> - <line text="Azpect.before"/> - <line text="B.main"/> - </stdout> - </run> - </ajc-test> - - <ajc-test dir="bugs198/github_120" title="annotation style C"> - <compile files="C.java" options="-1.5"/> - <run class="C"> - <stdout> - <line text="check if() pointcut running on C(1)"/> - <line text="Azpect1.beforeAdvice executing"/> - <line text="C.run() executing"/> - </stdout> - </run> - </ajc-test> - - <ajc-test dir="bugs198/github_120" title="annotation style D"> - <compile files="D.java" options="-1.5"/> - <run class="D"> - <stdout> - <line text="advice running"/> - <line text="D.run() executing"/> - </stdout> - </run> - </ajc-test> - - <ajc-test dir="bugs198/github_122" title="annotation style negated if"> - <compile files="E.java" options="-1.5"/> - <run class="E"> - <stdout> - <line text="advice running"/> - <line text="E.run() executing"/> - </stdout> - </run> - </ajc-test> - - <ajc-test dir="bugs198/github_125" title="compiler can re-open closed JARs"> - <!-- - Here the Java test sets system property org.aspectj.weaver.openarchives to 20 in order to provoke - open JAR limit exhaustion - --> - <compile files="Application.java" options="-1.5" /> - <run class="Application"> - <stdout> - <line text="Before advice"/> - <line text="Hello world!"/> - </stdout> - </run> - </ajc-test> - </suite> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml new file mode 100644 index 000000000..f76858a3b --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml @@ -0,0 +1,177 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + + +<suite> + + <!-- Java 18 final: no new features, only 2nd preview for "JEP 420: Pattern Matching for switch (Second Preview)" --> + <ajc-test dir="features199/java18" vm="18" title="dummy Java 18"> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features198/java17" vm="18" title="switch pattern matching error"> + <compile files="SwitchPatternError.java" options="--enable-preview -18"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternError.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features198/java17" vm="18" title="switch pattern matching java"> + <compile files="SwitchPatternOK.java" options="--enable-preview -18" /> + <run class="SwitchPatternOK" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features198/java17" vm="18" title="switch pattern matching aspect"> + <compile files="SwitchPatternAspect.aj" options="--enable-preview -18" /> + <run class="Application" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features199/java18" vm="18" title="switch pattern matching preview 2 error"> + <compile files="SwitchPatternPreview2Error.java" options="--enable-preview -18"> + <!-- TODO: Add correct compiler error message, as soon as JDT Core supports it --> + <message kind="error" file="SwitchPatternError.java" text="This case label is dominated by one of the preceding case label"/> + </compile> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features199/java18" vm="18" title="switch pattern matching preview 2 java"> + <compile files="SwitchPatternPreview2OK.java" options="--enable-preview -18" /> + <run class="SwitchPatternOK" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> + + <!-- Java ?? final, Java 17, 18 preview --> + <ajc-test dir="features199/java18" vm="18" title="switch pattern matching preview 2 aspect"> + <compile files="SwitchPatternPreview2Aspect.aj" options="--enable-preview -18" /> + <run class="Application" vmargs="--enable-preview"> + <stdout> + <line text="null" /> + <line text="int 123" /> + <line text="long 999" /> + <line text="double 12.340000" /> + <line text="String foo" /> + <line text="[123, foo, 999, 12.34]" /> + <line text="Non-circle" /> + <line text="Small circle" /> + <line text="Large circle" /> + <line text="Sealed sub-class A" /> + <line text="Sealed sub-class B" /> + <line text="Sealed sub-record C" /> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_115" title="annotation style A"> + <compile files="A.java" options="-1.5"> + <message kind="warning" line="28" text="advice defined in Azpect has not been applied [Xlint:adviceDidNotMatch]"/> + </compile> + <run class="A"> + <stdout> + <line text="Azpect.before"/> + <line text="A.main"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_115" title="annotation style B"> + <compile files="B.java" options="-1.5"/> + <run class="B"> + <stdout> + <line text="Azpect.before"/> + <line text="B.main"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_120" title="annotation style C"> + <compile files="C.java" options="-1.5"/> + <run class="C"> + <stdout> + <line text="check if() pointcut running on C(1)"/> + <line text="Azpect1.beforeAdvice executing"/> + <line text="C.run() executing"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_120" title="annotation style D"> + <compile files="D.java" options="-1.5"/> + <run class="D"> + <stdout> + <line text="advice running"/> + <line text="D.run() executing"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_122" title="annotation style negated if"> + <compile files="E.java" options="-1.5"/> + <run class="E"> + <stdout> + <line text="advice running"/> + <line text="E.run() executing"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_125" title="compiler can re-open closed JARs"> + <!-- + Here the Java test sets system property org.aspectj.weaver.openarchives to 20 in order to provoke + open JAR limit exhaustion + --> + <compile files="Application.java" options="-1.5" /> + <run class="Application"> + <stdout> + <line text="Before advice"/> + <line text="Hello world!"/> + </stdout> + </run> + </ajc-test> + +</suite> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc199/sanity-tests-18.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc199/sanity-tests-18.xml new file mode 100644 index 000000000..30c9660a1 --- /dev/null +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc199/sanity-tests-18.xml @@ -0,0 +1,70 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <!-- empty class --> + <ajc-test dir="bugs160/simplejava" title="simple - a"> + <compile files="SimpleA.java" options="-18"/> + </ajc-test> + + <!-- class with one method --> + <ajc-test dir="bugs160/simplejava" title="simple - b"> + <compile files="SimpleB.java" options="-18"/> + <run class="SimpleB"/> + </ajc-test> + + <!-- empty aspect --> + <ajc-test dir="bugs160/simplejava" title="simple - c"> + <compile files="SimpleC.java" options="-18"/> + </ajc-test> + + <!-- simple before --> + <ajc-test dir="bugs160/simplejava" title="simple - d"> + <compile files="SimpleD.java" options="-18"/> + </ajc-test> + + <!-- simple itd field --> + <ajc-test dir="bugs160/simplejava" title="simple - e"> + <compile files="SimpleE.java" options="-18"/> + </ajc-test> + + <!-- aspect with main calling a static method --> + <ajc-test dir="bugs160/simplejava" title="simple - f"> + <compile files="SimpleF.java" options="-18"/> + </ajc-test> + + <!-- pertarget --> + <ajc-test dir="bugs160/simplejava" title="simple - g"> + <compile files="SimpleG.java" options="-18"/> + </ajc-test> + + <!-- generic ctor itds --> + <ajc-test dir="bugs160/simplejava" title="simple - h"> + <compile files="SimpleH.java" options="-18"/> + </ajc-test> + + <!-- overriding generic itd methods --> + <ajc-test dir="bugs160/simplejava" title="simple - i"> + <compile files="SimpleI.java" options="-18"/> + </ajc-test> + + <!-- check class file version is 62.0 (Java 18) --> + <ajc-test dir="bugs160/simplejava" title="simple - j"> + <compile files="SimpleJ.java" options="-18"/> + </ajc-test> + + <!-- check class file version is 62.0 (Java 18) --> + <ajc-test dir="bugs160/simplejava" title="simple - k"> + <compile files="SimpleJ.java" options="-source 18"/> + </ajc-test> + + <!-- check class file version is 49.0 --> + <ajc-test dir="bugs160/simplejava" title="simple - m"> + <compile files="SimpleJ.java" options="-1.5"/> + </ajc-test> + + <ajc-test dir="bugs160/simplejava" title="simple - n"> + <compile files="SimpleN.java" options="-18"/> + </ajc-test> + +</suite> diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index af1e21d29..7e1c2a253 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -194,6 +194,10 @@ public class LangUtil { return 18 <= vmVersion; } + public static boolean is19VMOrGreater() { + return 19 <= vmVersion; + } + /** * Shorthand for "if null, throw IllegalArgumentException" * |