aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2021-06-26 16:16:18 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2021-06-26 16:51:19 +0700
commit9de03c3ea52f78678d8c47296395d5f01d031a48 (patch)
tree748d092412c09670f2781c38cea1ebe9b86c689d
parentdfcf1d77a65344934f0e642907819f16b5a3af0a (diff)
downloadaspectj-9de03c3ea52f78678d8c47296395d5f01d031a48.tar.gz
aspectj-9de03c3ea52f78678d8c47296395d5f01d031a48.zip
Add AspectJ 1.9.7 and Java 17 test skeletons
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
-rw-r--r--bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java6
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java39
-rw-r--r--testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17OrLater.java27
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/AllTests19.java2
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java64
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java30
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java47
-rw-r--r--tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java87
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml35
-rw-r--r--tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml70
-rw-r--r--util/src/main/java/org/aspectj/util/LangUtil.java4
11 files changed, 409 insertions, 2 deletions
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 285d024b6..1ce3682d3 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
@@ -96,8 +96,10 @@ public interface Constants {
short MINOR_15 = 0;
short MAJOR_16 = 60;
short MINOR_16 = 0;
-// short MAJOR_17 = 61;
-// short MINOR_17 = 0;
+ short MAJOR_17 = 61;
+ short MINOR_17 = 0;
+// short MAJOR_18 = 62;
+// short MINOR_18 = 0;
int PREVIEW_MINOR_VERSION = 65535;
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
new file mode 100644
index 000000000..e20ee7af7
--- /dev/null
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17Only.java
@@ -0,0 +1,39 @@
+/* *******************************************************************
+ * 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 XMLBasedAjcTestCaseForJava17Only extends XMLBasedAjcTestCase {
+
+ @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."
+ );
+ */
+ 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/XMLBasedAjcTestCaseForJava17OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17OrLater.java
new file mode 100644
index 000000000..1e18e2f7a
--- /dev/null
+++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava17OrLater.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 XMLBasedAjcTestCaseForJava17OrLater extends XMLBasedAjcTestCase {
+
+ @Override
+ public void setUp() throws Exception {
+ if (!LangUtil.is17VMOrGreater())
+ throw new IllegalStateException("These tests should be run on Java 17 or later");
+ super.setUp();
+ }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
index 4a52e8fe4..7223aff59 100644
--- a/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
+++ b/tests/src/test/java/org/aspectj/systemtest/AllTests19.java
@@ -17,6 +17,7 @@ import org.aspectj.systemtest.ajc196.AllTestsAspectJ196;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.aspectj.systemtest.ajc197.AllTestsAspectJ197;
+import org.aspectj.systemtest.ajc198.AllTestsAspectJ198;
/**
* @author Andy Clement
@@ -34,6 +35,7 @@ public class AllTests19 {
suite.addTest(AllTestsAspectJ195.suite());
suite.addTest(AllTestsAspectJ196.suite());
suite.addTest(AllTestsAspectJ197.suite());
+ suite.addTest(AllTestsAspectJ198.suite());
suite.addTest(AllTests18.suite());
// $JUnit-END$
return suite;
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java
new file mode 100644
index 000000000..172d6e14e
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Ajc198TestsJava.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.ajc198;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Ajc198TestsJava extends XMLBasedAjcTestCaseForJava17OrLater {
+
+ public void testHiddenClass() {
+ runTest("hidden class");
+ checkVersion("HiddenClassDemo", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testTextBlock1() {
+ runTest("textblock 1");
+ checkVersion("Code", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testTextBlock2() {
+ runTest("textblock 2");
+ checkVersion("Code2", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testRecords() {
+ runTest("simple record");
+ checkVersion("Person", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testRecords2() {
+ runTest("using a record");
+ checkVersion("UsingPersonRecord", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testAdvisingRecords() {
+ runTest("advising records");
+ checkVersion("TraceRecordComponents", Constants.MAJOR_17, Constants.MINOR_17);
+ }
+
+ public void testInstanceofPatterns() {
+ runTest("instanceof patterns");
+ checkVersion("Jep305", 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
new file mode 100644
index 000000000..26d749222
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/AllTestsAspectJ198.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.ajc198;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.aspectj.util.LangUtil;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class AllTestsAspectJ198 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.9.8 tests");
+ if (LangUtil.is17VMOrGreater()) {
+ suite.addTest(SanityTestsJava17.suite());
+ suite.addTest(Ajc198TestsJava.suite());
+ }
+ if (LangUtil.is17VMOrGreater() && !LangUtil.is18VMOrGreater()) {
+ suite.addTest(Java17PreviewFeaturesTests.suite());
+ }
+ return suite;
+ }
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java
new file mode 100644
index 000000000..fab787724
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/Java17PreviewFeaturesTests.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.ajc198;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava17Only;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Java17PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava17Only {
+
+/*
+ public void testSealedClassWithLegalSubclasses() {
+ runTest("sealed class with legal subclasses");
+ checkVersion("Employee", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+ checkVersion("Manager", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testSealedClassWithIllegalSubclass() {
+ runTest("sealed class with illegal subclass");
+ checkVersion("Person", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+ }
+
+ public void testWeaveSealedClass() {
+ runTest("weave sealed class");
+ checkVersion("PersonAspect", Constants.MAJOR_16, Constants.PREVIEW_MINOR_VERSION);
+ }
+*/
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Java17PreviewFeaturesTests.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("ajc198.xml");
+ }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.java
new file mode 100644
index 000000000..4fac5f375
--- /dev/null
+++ b/tests/src/test/java/org/aspectj/systemtest/ajc198/SanityTestsJava17.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.ajc198;
+
+import junit.framework.Test;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava17OrLater;
+
+/*
+ * 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 -10 option
+ * to check code generation and modification with that version specified.
+ *
+ * @author Alexander Kriegisch
+ */
+public class SanityTestsJava17 extends XMLBasedAjcTestCaseForJava17OrLater {
+
+ public static final int bytecode_version_for_JDK_level = 61;
+
+ // 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(SanityTestsJava17.class);
+ }
+
+ @Override
+ protected java.net.URL getSpecFile() {
+ return getClassResource("sanity-tests-17.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
new file mode 100644
index 000000000..e2dc9fe5d
--- /dev/null
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/ajc198.xml
@@ -0,0 +1,35 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+
+<suite>
+
+ <!-- Java ?? final, Java 16, 15 preview -->
+<!--
+ <ajc-test dir="features197/java15" vm="17" title="sealed class with legal subclasses">
+ <compile files="Person.java Employee.java Manager.java" options="&#45;&#45;enable-preview -16" />
+ </ajc-test>
+-->
+
+ <!-- Java ?? final, Java 16, 15 preview -->
+<!--
+ <ajc-test dir="features197/java15" vm="17" title="sealed class with illegal subclass">
+ <compile files="Person.java Employee.java Manager.java PersonaNonGrata.java" options="&#45;&#45;enable-preview -16">
+ <message kind="error" file="PersonaNonGrata.java" text="should be a permitted subtype of Person"/>
+ </compile>
+ </ajc-test>
+-->
+
+ <!-- Java ?? final, Java 16, 15 preview -->
+<!--
+ <ajc-test dir="features197/java15" vm="17" title="weave sealed class">
+ <compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="&#45;&#45;enable-preview -16" />
+ <run class="TopManager" vmargs="&#45;&#45;enable-preview">
+ <stdout>
+ <line text="Hello Sir John" />
+ <line text="CEO" />
+ </stdout>
+ </run>
+ </ajc-test>
+-->
+
+</suite>
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.xml
new file mode 100644
index 000000000..70f52fafa
--- /dev/null
+++ b/tests/src/test/resources/org/aspectj/systemtest/ajc198/sanity-tests-17.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="-17"/>
+ </ajc-test>
+
+ <!-- class with one method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - b">
+ <compile files="SimpleB.java" options="-17"/>
+ <run class="SimpleB"/>
+ </ajc-test>
+
+ <!-- empty aspect -->
+ <ajc-test dir="bugs160/simplejava" title="simple - c">
+ <compile files="SimpleC.java" options="-17"/>
+ </ajc-test>
+
+ <!-- simple before -->
+ <ajc-test dir="bugs160/simplejava" title="simple - d">
+ <compile files="SimpleD.java" options="-17"/>
+ </ajc-test>
+
+ <!-- simple itd field -->
+ <ajc-test dir="bugs160/simplejava" title="simple - e">
+ <compile files="SimpleE.java" options="-17"/>
+ </ajc-test>
+
+ <!-- aspect with main calling a static method -->
+ <ajc-test dir="bugs160/simplejava" title="simple - f">
+ <compile files="SimpleF.java" options="-17"/>
+ </ajc-test>
+
+ <!-- pertarget -->
+ <ajc-test dir="bugs160/simplejava" title="simple - g">
+ <compile files="SimpleG.java" options="-17"/>
+ </ajc-test>
+
+ <!-- generic ctor itds -->
+ <ajc-test dir="bugs160/simplejava" title="simple - h">
+ <compile files="SimpleH.java" options="-17"/>
+ </ajc-test>
+
+ <!-- overriding generic itd methods -->
+ <ajc-test dir="bugs160/simplejava" title="simple - i">
+ <compile files="SimpleI.java" options="-17"/>
+ </ajc-test>
+
+ <!-- check class file version is 60.0 (Java 16) -->
+ <ajc-test dir="bugs160/simplejava" title="simple - j">
+ <compile files="SimpleJ.java" options="-17"/>
+ </ajc-test>
+
+ <!-- check class file version is 60.0 (Java 16) -->
+ <ajc-test dir="bugs160/simplejava" title="simple - k">
+ <compile files="SimpleJ.java" options="-source 16"/>
+ </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="-17"/>
+ </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 c53d18989..187b895b2 100644
--- a/util/src/main/java/org/aspectj/util/LangUtil.java
+++ b/util/src/main/java/org/aspectj/util/LangUtil.java
@@ -190,6 +190,10 @@ public class LangUtil {
return 17 <= vmVersion;
}
+ public static boolean is18VMOrGreater() {
+ return 18 <= vmVersion;
+ }
+
/**
* Shorthand for "if null, throw IllegalArgumentException"
*