]> source.dussan.org Git - aspectj.git/commitdiff
Add Java 16 test suite for AspectJ 1.9.7 + test refactorings
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 20 Mar 2021 19:16:20 +0000 (02:16 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 20 Mar 2021 19:16:20 +0000 (02:16 +0700)
- Test all features which were preview in 14+15 and are now final in 16,
  compiling them with language level 16.
- For Java 15 we only have sanity tests (and of course the Java <14
  tests), compiling Java 16 features to target 15 does not seem to work.
- Test remaining Java 16 preview feature (sealed classes).
- Instead of overriding runTest(String) in several base classes like
  XMLBasedAjcTestCaseForJava*Only or XMLBasedAjcTestCaseForJava*OrLater,
  we now override setUp() from JUnit's TestCase base class. This will
  run before runTest(String) and make the tests fail much faster, if a
  user tries to run them on the wrong VM.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
24 files changed:
bcel-builder/src/main/java/org/aspectj/apache/bcel/Constants.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava11OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava12OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava13OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14Only.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava14OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15OrLater.java
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java [new file with mode: 0644]
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java [new file with mode: 0644]
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java
tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196PreviewFeaturesTests.java [deleted file]
tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java
tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java [deleted file]
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197Tests.java [deleted file]
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java [new file with mode: 0644]
tests/src/test/resources/org/aspectj/systemtest/ajc197/ajc197.xml
tests/src/test/resources/org/aspectj/systemtest/ajc197/sanity-tests-16.xml [new file with mode: 0644]
util/src/main/java/org/aspectj/util/LangUtil.java

index fbf88ae88c0807f22fbefbd2700194143753bcde..285d024b64ea25783f0642fedd4fdb9ad08ab6a9 100644 (file)
@@ -94,8 +94,8 @@ public interface Constants {
        short MINOR_14 = 0;
        short MAJOR_15 = 59;
        short MINOR_15 = 0;
-//     short MAJOR_16 = 60;
-//     short MINOR_16 = 0;
+       short MAJOR_16 = 60;
+       short MINOR_16 = 0;
 //     short MAJOR_17 = 61;
 //     short MINOR_17 = 0;
 
index 4a8c63f11c7e2939e73de6b42702a90e23bda9a0..753de0c8095600cff470dbee327f16a80a586803 100644 (file)
@@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava10OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is10VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is10VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 10 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
        
 }
index 18181d60eb1b58808179d893db1dbd15a28836c2..1bfcdd580a71a0b84d54e12bcc17b26713fafa58 100644 (file)
@@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava11OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is11VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is11VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 11 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
        
 }
index c3242a36b64c73c42e4f3ce583ca98e35f90d4bc..e1a847f4e574f1c3274c2ec4a088eb76bb238fe9 100644 (file)
@@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava12OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is12VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is12VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 12 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
        
 }
index 92193f540c68c00e65f923dab5f08fa158d5ec9f..2ce1ee80ee33d840b121e44dadfe6ecf8d1b5b28 100644 (file)
@@ -21,11 +21,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava13OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is13VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is13VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 13 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
 
 }
index 5a25c9a7322f3c9152018fb431cb06210df82438..8e90ead3a44b4ad6e0ad2ce5ba906f7ab2599444 100644 (file)
@@ -8,8 +8,6 @@
  * ******************************************************************/
 package org.aspectj.testing;
 
-import org.aspectj.util.LangUtil;
-
 /**
  * Makes sure tests are running on the right level of JDK.
  *
@@ -18,7 +16,7 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
+       public void setUp() throws Exception {
                throw new IllegalStateException(
                        "These tests need a Java 14 level AspectJ compiler " +
                                "(e.g. because they use version-specific preview features). " +
@@ -31,7 +29,7 @@ public abstract class XMLBasedAjcTestCaseForJava14Only extends XMLBasedAjcTestCa
                                "(e.g. because they use version-specific preview features)"
                        );
                }
-               super.runTest(title);
+               super.setUp();
                */
        }
 
index 15c1ac568de9e4b659bddfde328e9ac5c0c60fa6..73df02f4a3973a6e53dd2b02e61d82cd39edef08 100644 (file)
@@ -18,11 +18,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava14OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is14VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is14VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 14 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
 
 }
index 82fe4045c5c6419826b5ca8314f4d89afeb78513..0e9f43d83bc785bc3efbc742d4c2d4c03278a1f8 100644 (file)
@@ -8,8 +8,6 @@
  * ******************************************************************/
 package org.aspectj.testing;
 
-import org.aspectj.util.LangUtil;
-
 /**
  * Makes sure tests are running on the right level of JDK.
  *
@@ -18,22 +16,21 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava15Only extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               // Activate this block after upgrading to JDT Core Java 16
-               /*
+       public void setUp() throws Exception {
                throw new IllegalStateException(
                        "These tests need a Java 15 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.is15VMOrGreater() || LangUtil.is16VMOrGreater()) {
                        throw new IllegalStateException(
                                "These tests should be run on Java 15 only " +
                                "(e.g. because they use version-specific preview features)"
                        );
                }
-               super.runTest(title);
+               super.setUp();
+               */
        }
 
 }
index 90b7feda176e212fc852009ee5afb0c18e1e5ee9..72033daf55ba4c0dc45235a7a9227f01db2d5652 100644 (file)
@@ -1,5 +1,5 @@
 /* *******************************************************************
- * Copyright (c) 2020 Contributors
+ * Copyright (c) 2021 Contributors
  * All rights reserved.
  * This program and the accompanying materials are made available
  * under the terms of the Eclipse Public License v1.0
@@ -13,16 +13,15 @@ import org.aspectj.util.LangUtil;
 /**
  * Makes sure tests are running on the right level of JDK.
  *
- * @author Andy Clement
+ * @author Alexander Kriegisch
  */
 public abstract class XMLBasedAjcTestCaseForJava15OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               if (!LangUtil.is15VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is15VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 15 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
 
 }
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16Only.java
new file mode 100644 (file)
index 0000000..dc51db8
--- /dev/null
@@ -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 v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * ******************************************************************/
+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 XMLBasedAjcTestCaseForJava16Only extends XMLBasedAjcTestCase {
+
+       @Override
+       public void setUp() throws Exception {
+               // Activate this block after upgrading to JDT Core Java 17
+               /*
+               throw new IllegalStateException(
+                       "These tests need a Java 16 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.is16VMOrGreater() || LangUtil.is17VMOrGreater()) {
+                       throw new IllegalStateException(
+                               "These tests should be run on Java 16 only " +
+                               "(e.g. because they use version-specific preview features)"
+                       );
+               }
+               super.setUp();
+       }
+
+}
diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava16OrLater.java
new file mode 100644 (file)
index 0000000..6fd29c8
--- /dev/null
@@ -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 v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * ******************************************************************/
+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 XMLBasedAjcTestCaseForJava16OrLater extends XMLBasedAjcTestCase {
+
+       @Override
+       public void setUp() throws Exception {
+               if (!LangUtil.is16VMOrGreater())
+                       throw new IllegalStateException("These tests should be run on Java 16 or later");
+               super.setUp();
+       }
+
+}
index 19e80c47466462ac2431b719932537d223724637..0be3424ef662dfd77ecf7e9ee61cb0ee11a77ef2 100644 (file)
@@ -21,12 +21,10 @@ import org.aspectj.util.LangUtil;
 public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTestCase {
 
        @Override
-       public void runTest(String title) {
-               // Check we are on Java9 or later
-               if (!LangUtil.is9VMOrGreater()) {
+       public void setUp() throws Exception {
+               if (!LangUtil.is9VMOrGreater())
                        throw new IllegalStateException("These tests should be run on Java 9 or later");
-               }
-               super.runTest(title);
+               super.setUp();
        }
 
 }
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196PreviewFeaturesTests.java
deleted file mode 100644 (file)
index 56c95a2..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2021 Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.aspectj.systemtest.ajc196;
-
-import org.aspectj.apache.bcel.Constants;
-import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava14Only;
-
-import junit.framework.Test;
-
-/**
- * @author Alexander Kriegisch
- */
-public class Ajc196PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava14Only {
-
-  public void testRecords() {
-    runTest("simple record");
-    checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION);
-  }
-
-  public void testRecords2() {
-    runTest("using a record");
-  }
-
-  public void testInstanceofPatterns() {
-    runTest("instanceof patterns");
-  }
-
-  public void testAdvisingRecords() {
-    runTest("advising records");
-  }
-
-  public void testTextBlock1() {
-    runTest("textblock 1");
-  }
-
-  public void testTextBlock2() {
-    runTest("textblock 2");
-  }
-
-  // ---
-
-  public static Test suite() {
-    return XMLBasedAjcTestCase.loadSuite(Ajc196PreviewFeaturesTests.class);
-  }
-
-  @Override
-  protected java.net.URL getSpecFile() {
-    return getClassResource("ajc196.xml");
-  }
-
-}
index 7fd25c04bb44c5fbc7279dd92357c79154a2120a..045ef6e4723968f135ec5d9da8b7add56c9c4729 100644 (file)
@@ -37,8 +37,6 @@ public class Ajc196Tests extends XMLBasedAjcTestCaseForJava14OrLater {
     checkVersion("Switch3", Constants.MAJOR_14, 0);
   }
 
-  // ---
-
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Ajc196Tests.class);
   }
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/Java14PreviewFeaturesTests.java
new file mode 100644 (file)
index 0000000..28a2a75
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc196;
+
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava14Only;
+
+import junit.framework.Test;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Java14PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava14Only {
+
+  public void testRecords() {
+    runTest("simple record");
+    checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION);
+  }
+
+  public void testRecords2() {
+    runTest("using a record");
+  }
+
+  public void testInstanceofPatterns() {
+    runTest("instanceof patterns");
+  }
+
+  public void testAdvisingRecords() {
+    runTest("advising records");
+  }
+
+  public void testTextBlock1() {
+    runTest("textblock 1");
+  }
+
+  public void testTextBlock2() {
+    runTest("textblock 2");
+  }
+
+  public static Test suite() {
+    return XMLBasedAjcTestCase.loadSuite(Java14PreviewFeaturesTests.class);
+  }
+
+  @Override
+  protected java.net.URL getSpecFile() {
+    return getClassResource("ajc196.xml");
+  }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java
deleted file mode 100644 (file)
index 2c26ca4..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2021 Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.aspectj.systemtest.ajc197;
-
-import junit.framework.Test;
-import org.aspectj.apache.bcel.Constants;
-import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava15Only;
-
-/**
- * @author Alexander Kriegisch
- */
-public class Ajc197PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava15Only {
-
-  public void testRecords() {
-    runTest("simple record");
-    checkVersion("Person", Constants.MAJOR_15, Constants.PREVIEW_MINOR_VERSION);
-  }
-
-  public void testRecords2() {
-    runTest("using a record");
-  }
-
-  public void testInstanceofPatterns() {
-    runTest("instanceof patterns");
-  }
-
-  public void testAdvisingRecords() {
-    runTest("advising records");
-  }
-
-  public void testSealedClassWithLegalSubclasses() {
-    runTest("sealed class with legal subclasses");
-  }
-
-  public void testSealedClassWithIllegalSubclass() {
-    runTest("sealed class with illegal subclass");
-  }
-
-  public void testWeaveSealedClass() {
-    runTest("weave sealed class");
-  }
-
-  public static Test suite() {
-    return XMLBasedAjcTestCase.loadSuite(Ajc197PreviewFeaturesTests.class);
-  }
-
-  @Override
-  protected java.net.URL getSpecFile() {
-    return getClassResource("ajc197.xml");
-  }
-
-}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197Tests.java
deleted file mode 100644 (file)
index bd6600f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2021 Contributors
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.aspectj.systemtest.ajc197;
-
-import junit.framework.Test;
-import org.aspectj.testing.XMLBasedAjcTestCase;
-import org.aspectj.testing.XMLBasedAjcTestCaseForJava15OrLater;
-
-/**
- * @author Alexander Kriegisch
- */
-public class Ajc197Tests extends XMLBasedAjcTestCaseForJava15OrLater {
-
-  public void testHiddenClass() {
-    runTest("hidden class");
-  }
-
-  public void testTextBlock1() {
-    runTest("textblock 1");
-  }
-
-  public void testTextBlock2() {
-    runTest("textblock 2");
-  }
-
-  public static Test suite() {
-    return XMLBasedAjcTestCase.loadSuite(Ajc197Tests.class);
-  }
-
-  @Override
-  protected java.net.URL getSpecFile() {
-    return getClassResource("ajc197.xml");
-  }
-
-}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197TestsJava.java
new file mode 100644 (file)
index 0000000..081da97
--- /dev/null
@@ -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 v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc197;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Ajc197TestsJava extends XMLBasedAjcTestCaseForJava16OrLater {
+
+  public void testHiddenClass() {
+    runTest("hidden class");
+    checkVersion("HiddenClassDemo", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testTextBlock1() {
+    runTest("textblock 1");
+    checkVersion("Code", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testTextBlock2() {
+    runTest("textblock 2");
+    checkVersion("Code2", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testRecords() {
+    runTest("simple record");
+    checkVersion("Person", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testRecords2() {
+    runTest("using a record");
+    checkVersion("UsingPersonRecord", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testAdvisingRecords() {
+    runTest("advising records");
+    checkVersion("TraceRecordComponents", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public void testInstanceofPatterns() {
+    runTest("instanceof patterns");
+    checkVersion("Jep305", Constants.MAJOR_16, Constants.MINOR_16);
+  }
+
+  public static Test suite() {
+    return XMLBasedAjcTestCase.loadSuite(Ajc197TestsJava.class);
+  }
+
+  @Override
+  protected java.net.URL getSpecFile() {
+    return getClassResource("ajc197.xml");
+  }
+
+}
index 2b33099cbe4e158b290571d1d9beedaab18d82da..995cd297692d2305d19c6920060d36a6cc2050d4 100644 (file)
@@ -19,11 +19,14 @@ public class AllTestsAspectJ197 {
        public static Test suite() {
                TestSuite suite = new TestSuite("AspectJ 1.9.7 tests");
                if (LangUtil.is15VMOrGreater()) {
-                       suite.addTest(Ajc197Tests.suite());
                        suite.addTest(SanityTestsJava15.suite());
                }
-               if (LangUtil.is15VMOrGreater() && !LangUtil.is16VMOrGreater()) {
-                       suite.addTest(Ajc197PreviewFeaturesTests.suite());
+               if (LangUtil.is16VMOrGreater()) {
+                       suite.addTest(SanityTestsJava16.suite());
+                       suite.addTest(Ajc197TestsJava.suite());
+               }
+               if (LangUtil.is16VMOrGreater() && !LangUtil.is17VMOrGreater()) {
+                       suite.addTest(Java16PreviewFeaturesTests.suite());
                }
                return suite;
        }
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Java16PreviewFeaturesTests.java
new file mode 100644 (file)
index 0000000..e0c68cc
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc197;
+
+import junit.framework.Test;
+import org.aspectj.apache.bcel.Constants;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava16Only;
+
+/**
+ * @author Alexander Kriegisch
+ */
+public class Java16PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava16Only {
+
+  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(Java16PreviewFeaturesTests.class);
+  }
+
+  @Override
+  protected java.net.URL getSpecFile() {
+    return getClassResource("ajc197.xml");
+  }
+
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava16.java
new file mode 100644 (file)
index 0000000..ed050f5
--- /dev/null
@@ -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 v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc197;
+
+import junit.framework.Test;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava16OrLater;
+
+/*
+ * 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 SanityTestsJava16 extends XMLBasedAjcTestCaseForJava16OrLater {
+
+       public static final int bytecode_version_for_JDK_level = 60;
+
+       // 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(SanityTestsJava16.class);
+       }
+
+       @Override
+       protected java.net.URL getSpecFile() {
+               return getClassResource("sanity-tests-16.xml");
+       }
+
+}
index 6f6edaff51598901795b71bdab59646cf1e098d5..7ba29cde5ac27888ccbbff604f0a72ecc278d453 100644 (file)
@@ -2,9 +2,10 @@
 
 <suite>
 
-       <ajc-test dir="features197/java15" vm="15" title="hidden class">
-               <compile files="HiddenClassDemo.java" options="-15" />
-               <compile files="HiddenClass.java" options="-15 -outjar hidden.jar"/>
+       <!-- Java 15 final, no preview -->
+       <ajc-test dir="features197/java15" vm="16" title="hidden class">
+               <compile files="HiddenClassDemo.java" options="-16" />
+               <compile files="HiddenClass.java" options="-16 -outjar hidden.jar"/>
                <run class="HiddenClassDemo" classpath="hidden.jar">
                        <stdout>
                                <line text="Hidden class name = HiddenClass/" />
                </run>
        </ajc-test>
 
-       <ajc-test dir="features196/java14" vm="15" title="simple record">
-               <compile files="Person.java" options="--enable-preview -15" />
+       <!-- Java 16 final, Java 15, 14 preview -->
+       <ajc-test dir="features196/java14" vm="16" title="simple record">
+               <compile files="Person.java" options="-16" />
        </ajc-test>
 
-       <ajc-test dir="features196/java14" vm="15" title="using a record">
-               <compile files="Person.java UsingPersonRecord.java"
-                       options="--enable-preview -15" />
-               <run class="UsingPersonRecord" vmargs="--enable-preview">
+       <!-- Java 16 final, Java 15, 14 preview -->
+       <ajc-test dir="features196/java14" vm="16" title="using a record">
+               <compile files="Person.java UsingPersonRecord.java" options="-16" />
+               <run class="UsingPersonRecord">
                        <stdout>
                                <line text="Person[firstName=A, lastName=B, age=99]" />
                                <line text="A" />
                </run>
        </ajc-test>
 
-       <ajc-test dir="features196/java14" vm="15"
-               title="instanceof patterns">
-               <compile files="Jep305.java" options="--enable-preview -15" />
-               <run class="Jep305" vmargs="--enable-preview">
+       <!-- Java 16 final, Java 15, 14 preview -->
+       <ajc-test dir="features196/java14" vm="16" title="advising records">
+               <compile files="TraceRecordComponents.aj Person.java UsingPersonRecord.java" options="-16" />
+               <run class="UsingPersonRecord">
                        <stdout>
-                               <line text="orange" />
-                               <line text="apple" />
+                               <line text="execution(String Person.toString())" />
+                               <line text="Person[firstName=A, lastName=B, age=99]" />
+                               <line text="execution(String Person.firstName())" />
+                               <line text="A" />
                        </stdout>
                </run>
        </ajc-test>
 
-       <ajc-test dir="features196/java14" vm="15"
-               title="advising records">
-               <compile
-                       files="TraceRecordComponents.aj Person.java UsingPersonRecord.java"
-                       options="--enable-preview -15" />
-               <run class="UsingPersonRecord" vmargs="--enable-preview">
+       <!-- Java 16 final, Java 15, 14 preview -->
+       <ajc-test dir="features196/java14" vm="16" title="instanceof patterns">
+               <compile files="Jep305.java" options="-16" />
+               <run class="Jep305">
                        <stdout>
-                               <line text="execution(String Person.toString())" />
-                               <line text="Person[firstName=A, lastName=B, age=99]" />
-                               <line text="execution(String Person.firstName())" />
-                               <line text="A" />
+                               <line text="orange" />
+                               <line text="apple" />
                        </stdout>
                </run>
        </ajc-test>
 
-       <!-- textblock now in Java15 and doesn't need -enable-preview flag -->
-       <ajc-test dir="features195/textblock" vm="15"
-               title="textblock 1">
-               <compile files="Code.java"
-                       options="-source 15">
+       <!-- Java 15 final, Java 14, 13 preview -->
+       <ajc-test dir="features195/textblock" vm="16" title="textblock 1">
+               <compile files="Code.java" options="-source 16">
                </compile>
                <run class="Code">
                        <stdout>
                </run>
        </ajc-test>
 
-       <!-- textblock now in Java15 and doesn't need -enable-preview flag -->
-       <ajc-test dir="features195/textblock" vm="15"
-               title="textblock 2">
-               <compile files="Code2.java"
-                       options="-source 15">
+       <!-- Java 15 final, Java 14, 13 preview -->
+       <ajc-test dir="features195/textblock" vm="16" title="textblock 2">
+               <compile files="Code2.java" options="-source 16">
                </compile>
                <run class="Code2">
                        <stdout>
                </run>
        </ajc-test>
 
-       <ajc-test dir="features197/java15" vm="15" title="sealed class with legal subclasses">
-               <compile files="Person.java Employee.java Manager.java" options="--enable-preview -15" />
+       <!-- Java ?? final, Java 16, 15 preview -->
+       <ajc-test dir="features197/java15" vm="16" title="sealed class with legal subclasses">
+               <compile files="Person.java Employee.java Manager.java" options="--enable-preview -16" />
        </ajc-test>
 
-       <ajc-test dir="features197/java15" vm="15" title="sealed class with illegal subclass">
-               <compile files="Person.java  Employee.java Manager.java PersonaNonGrata.java" options="--enable-preview -15">
+       <!-- Java ?? final, Java 16, 15 preview -->
+       <ajc-test dir="features197/java15" vm="16" title="sealed class with illegal subclass">
+               <compile files="Person.java  Employee.java Manager.java PersonaNonGrata.java" options="--enable-preview -16">
                        <message kind="error" file="PersonaNonGrata.java" text="should be a permitted subtype of Person"/>
                </compile>
        </ajc-test>
 
-       <ajc-test dir="features197/java15" vm="15" title="weave sealed class">
-               <compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="--enable-preview -15" />
+       <!-- Java ?? final, Java 16, 15 preview -->
+       <ajc-test dir="features197/java15" vm="16" title="weave sealed class">
+               <compile files="Person.java Employee.java Manager.java TopManager.java PersonAspect.aj" options="--enable-preview -16" />
                <run class="TopManager" vmargs="--enable-preview">
                        <stdout>
                                <line text="Hello Sir John" />
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc197/sanity-tests-16.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc197/sanity-tests-16.xml
new file mode 100644 (file)
index 0000000..d6cb9ab
--- /dev/null
@@ -0,0 +1,69 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+    <!-- empty class -->
+    <ajc-test dir="bugs160/simplejava" title="simple - a">
+      <compile files="SimpleA.java" options="-16"/>
+    </ajc-test>
+
+    <!-- class with one method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - b">
+      <compile files="SimpleB.java" options="-16"/>
+      <run class="SimpleB"/>
+    </ajc-test>
+
+    <!-- empty aspect -->
+    <ajc-test dir="bugs160/simplejava" title="simple - c">
+      <compile files="SimpleC.java" options="-16"/>
+    </ajc-test>
+
+    <!-- simple before -->
+    <ajc-test dir="bugs160/simplejava" title="simple - d">
+      <compile files="SimpleD.java" options="-16"/>
+    </ajc-test>
+
+    <!-- simple itd field -->
+    <ajc-test dir="bugs160/simplejava" title="simple - e">
+      <compile files="SimpleE.java" options="-16"/>
+    </ajc-test>
+
+    <!-- aspect with main calling a static method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - f">
+      <compile files="SimpleF.java" options="-16"/>
+    </ajc-test>
+
+    <!-- pertarget -->
+    <ajc-test dir="bugs160/simplejava" title="simple - g">
+      <compile files="SimpleG.java" options="-16"/>
+    </ajc-test>
+
+    <!-- generic ctor itds -->
+    <ajc-test dir="bugs160/simplejava" title="simple - h">
+      <compile files="SimpleH.java" options="-16"/>
+    </ajc-test>
+
+    <!-- overriding generic itd methods -->
+    <ajc-test dir="bugs160/simplejava" title="simple - i">
+      <compile files="SimpleI.java" options="-16"/>
+    </ajc-test>
+
+    <!-- check class file version is 60.0 (Java 16) -->
+    <ajc-test dir="bugs160/simplejava" title="simple - j">
+      <compile files="SimpleJ.java" options="-16"/>
+    </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="-16"/>
+    </ajc-test>
+</suite>
index a0535d38932c643d494fec37ea670d82429ff73c..8128174aa6605e52707a5e24568a6e13a83eec78 100644 (file)
@@ -186,6 +186,10 @@ public class LangUtil {
                return 16 <= vmVersion;
        }
 
+       public static boolean is17VMOrGreater() {
+               return 17 <= vmVersion;
+       }
+
        /**
         * Shorthand for "if null, throw IllegalArgumentException"
         *