aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2022-03-21 10:45:00 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2022-03-21 10:51:35 +0700
commit6dc09db0ca1589f8c53c4dca054e3a852eaaecba (patch)
tree9c480f1ab92b26d141a249513d89942b1a1e6b73 /tests
parentd3a06a6942b6f69ce9b5b4403d3c1cf1803cf01e (diff)
downloadaspectj-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>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs199/github_115/A.java (renamed from tests/bugs198/github_115/A.java)0
-rw-r--r--tests/bugs199/github_115/B.java (renamed from tests/bugs198/github_115/B.java)0
-rw-r--r--tests/bugs199/github_120/C.java (renamed from tests/bugs198/github_120/C.java)0
-rw-r--r--tests/bugs199/github_120/D.java (renamed from tests/bugs198/github_120/D.java)0
-rw-r--r--tests/bugs199/github_122/E.java (renamed from tests/bugs198/github_122/E.java)0
-rw-r--r--tests/bugs199/github_125/Application.java (renamed from tests/bugs198/github_125/Application.java)0
-rw-r--r--tests/features199/java18/SwitchPatternPreview2Aspect.aj28
-rw-r--r--tests/features199/java18/SwitchPatternPreview2Error.java31
-rw-r--r--tests/features199/java18/SwitchPatternPreview2OK.java38
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java54
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java3
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/Bugs198Tests.java27
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc199/Ajc199TestsJava.java32
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc199/AllTestsAspectJ199.java31
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java56
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc199/Java18PreviewFeaturesTests.java69
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc199/SanityTestsJava18.java87
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml69
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml177
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc199/sanity-tests-18.xml70
20 files changed, 647 insertions, 125 deletions
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>