]> source.dussan.org Git - aspectj.git/commitdiff
Add Java 15 / AspectJ 1.9.7 test suite 36/head 38/head
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 17 Mar 2021 16:38:08 +0000 (23:38 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 17 Mar 2021 16:38:08 +0000 (23:38 +0700)
Also fix some minor details in Java 14 suite

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
19 files changed:
testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java [new file with mode: 0644]
tests/features197/java15/Employee.java [new file with mode: 0644]
tests/features197/java15/HiddenClass.java [new file with mode: 0644]
tests/features197/java15/HiddenClassDemo.java [new file with mode: 0644]
tests/features197/java15/Manager.java [new file with mode: 0644]
tests/features197/java15/Person.java [new file with mode: 0644]
tests/features197/java15/PersonAspect.aj [new file with mode: 0644]
tests/features197/java15/PersonaNonGrata.java [new file with mode: 0644]
tests/features197/java15/TopManager.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/AllTests19.java
tests/src/test/java/org/aspectj/systemtest/ajc196/SanityTestsJava14.java
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197Tests.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java [new file with mode: 0644]
tests/src/test/resources/org/aspectj/systemtest/ajc196/sanity-tests-14.xml
tests/src/test/resources/org/aspectj/systemtest/ajc197/ajc197.xml [new file with mode: 0644]
tests/src/test/resources/org/aspectj/systemtest/ajc197/sanity-tests-15.xml [new file with mode: 0644]
util/src/main/java/org/aspectj/util/LangUtil.java

diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCaseForJava15Only.java
new file mode 100644 (file)
index 0000000..82fe404
--- /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 XMLBasedAjcTestCaseForJava15Only extends XMLBasedAjcTestCase {
+
+       @Override
+       public void runTest(String title) {
+               // Activate this block after upgrading to JDT Core Java 16
+               /*
+               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);
+       }
+
+}
diff --git a/tests/features197/java15/Employee.java b/tests/features197/java15/Employee.java
new file mode 100644 (file)
index 0000000..9b0b9da
--- /dev/null
@@ -0,0 +1 @@
+public final class Employee extends Person {}
diff --git a/tests/features197/java15/HiddenClass.java b/tests/features197/java15/HiddenClass.java
new file mode 100644 (file)
index 0000000..f1ef611
--- /dev/null
@@ -0,0 +1,6 @@
+public class HiddenClass implements Test {
+  @Override
+  public void concat(String... words) {
+    System.out.println(String.join(" ", words));
+  }
+}
diff --git a/tests/features197/java15/HiddenClassDemo.java b/tests/features197/java15/HiddenClassDemo.java
new file mode 100644 (file)
index 0000000..0b7f0ab
--- /dev/null
@@ -0,0 +1,39 @@
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Constructor;
+
+import java.io.FileInputStream;
+
+import static java.lang.invoke.MethodHandles.Lookup.ClassOption.NESTMATE;
+
+public class HiddenClassDemo {
+  public static void main(String[] args) throws Throwable {
+    // Step 1: Create lookup object
+    MethodHandles.Lookup lookup = MethodHandles.lookup();
+
+    // Step 2: Fetch or create the class bytes we want to define
+    byte[] bytes = Thread.currentThread().getContextClassLoader()
+      .getResourceAsStream("HiddenClass.class")
+      .readAllBytes();
+
+    // Step 3: Define hidden class
+    Class<?> clazz = lookup.defineHiddenClass(bytes, true, NESTMATE).lookupClass();
+    // Hidden classes have class names like my.package.MyClass/0x2a23f5, but no canonical name (null)
+    System.out.println("Hidden class name = " + clazz.getName());
+    System.out.println("Hidden class canonical name = " + clazz.getCanonicalName ());
+    // Hidden classes cannot be resolved by any class loader (ClassNotFoundException)
+    try {
+      Class.forName(clazz.getName());
+    }
+    catch (ClassNotFoundException e) {
+      System.out.println("Class.forName resolution error = " + e);
+    }
+
+    //Step 4: Create instance of hidden class object and call interface method
+    Test test = (Test) clazz.getConstructor(null).newInstance(null);
+    test.concat("Hello", "from", "dynamically", "defined", "hidden", "class");
+  }
+}
+
+interface Test {
+  void concat(String... words);
+}
diff --git a/tests/features197/java15/Manager.java b/tests/features197/java15/Manager.java
new file mode 100644 (file)
index 0000000..09b897d
--- /dev/null
@@ -0,0 +1 @@
+public non-sealed class Manager extends Person {}
diff --git a/tests/features197/java15/Person.java b/tests/features197/java15/Person.java
new file mode 100644 (file)
index 0000000..cdd87d7
--- /dev/null
@@ -0,0 +1,5 @@
+public abstract sealed class Person permits Employee, Manager {
+  public void sayHello(String name) {
+    System.out.println("Hello " + name);
+  }
+}
diff --git a/tests/features197/java15/PersonAspect.aj b/tests/features197/java15/PersonAspect.aj
new file mode 100644 (file)
index 0000000..695a4de
--- /dev/null
@@ -0,0 +1,17 @@
+public aspect PersonAspect {
+  // Weave into sealed class
+  void around(String name): execution(void sayHello(*)) && args(name) {
+    proceed("Sir " + name);
+  }
+
+  // ITD into non-sealed subclass of sealed class
+  private String Manager.jobTitle;
+
+  public void TopManager.setJobTitle(String jobTitle) {
+    this.jobTitle = jobTitle;
+  }
+
+  public String TopManager.getJobTitle() {
+    return jobTitle;
+  }
+}
diff --git a/tests/features197/java15/PersonaNonGrata.java b/tests/features197/java15/PersonaNonGrata.java
new file mode 100644 (file)
index 0000000..fc80153
--- /dev/null
@@ -0,0 +1,2 @@
+// This should not compile because Person is sealed and does not allow PersonaNonGrata as a subclass
+public final class PersonaNonGrata extends Person {}
diff --git a/tests/features197/java15/TopManager.java b/tests/features197/java15/TopManager.java
new file mode 100644 (file)
index 0000000..e1dfdc3
--- /dev/null
@@ -0,0 +1,10 @@
+public class TopManager extends Manager {
+  public static void main(String[] args) {
+    TopManager topManager = new TopManager();
+    topManager.sayHello("John");
+
+    // Call ITD methods
+    topManager.setJobTitle("CEO");
+    System.out.println(topManager.getJobTitle());
+  }
+}
index 20ecc38942b404bbb09b4c5aab639f3d991188b4..418ecbff54fe4272d3b5ef6372da2e3c775fd226 100644 (file)
@@ -16,6 +16,7 @@ import org.aspectj.systemtest.ajc196.AllTestsAspectJ196;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+import org.aspectj.systemtest.ajc197.AllTestsAspectJ197;
 
 /**
  * @author Andy Clement
@@ -32,6 +33,7 @@ public class AllTests19 {
                // there were no new tests for 1.9.4
                suite.addTest(AllTestsAspectJ195.suite());
                suite.addTest(AllTestsAspectJ196.suite());
+               suite.addTest(AllTestsAspectJ197.suite());
                suite.addTest(AllTests18.suite());
                // $JUnit-END$
                return suite;
index edf08298c5ba78d648711b66aba199e6dd6e34ae..a07e3afa491d2b0bbd36457a385f9cd34669dff1 100644 (file)
@@ -60,23 +60,22 @@ public class SanityTestsJava14 extends XMLBasedAjcTestCaseForJava14OrLater {
                runTest("simple - i");
        }
 
-       public void testVersionCorrect1() throws ClassNotFoundException {
+       public void testVersionCorrect1() {
                runTest("simple - j");
                checkVersion("A", bytecode_version_for_JDK_level, 0);
        }
 
-       public void testVersionCorrect2() throws ClassNotFoundException {
+       public void testVersionCorrect2() {
                runTest("simple - k");
                checkVersion("A", bytecode_version_for_JDK_level, 0);
        }
 
-       public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified
+       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(SanityTestsJava14.class);
        }
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/Ajc197PreviewFeaturesTests.java
new file mode 100644 (file)
index 0000000..2c26ca4
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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
new file mode 100644 (file)
index 0000000..bd6600f
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2021 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 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/AllTestsAspectJ197.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/AllTestsAspectJ197.java
new file mode 100644 (file)
index 0000000..2b33099
--- /dev/null
@@ -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 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 junit.framework.TestSuite;
+import org.aspectj.util.LangUtil;
+
+/**
+ * @author Alexander Kriegisch
+ */
+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());
+               }
+               return suite;
+       }
+}
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java b/tests/src/test/java/org/aspectj/systemtest/ajc197/SanityTestsJava15.java
new file mode 100644 (file)
index 0000000..8a9d5c3
--- /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.XMLBasedAjcTestCaseForJava15OrLater;
+
+/*
+ * 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 SanityTestsJava15 extends XMLBasedAjcTestCaseForJava15OrLater {
+
+       public static final int bytecode_version_for_JDK_level = 59;
+
+       // 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(SanityTestsJava15.class);
+       }
+
+       @Override
+       protected java.net.URL getSpecFile() {
+               return getClassResource("sanity-tests-15.xml");
+       }
+
+}
index e831c99160bfdc128d69e5d6c369fc736081d1ce..a1a4a81c631a9af23ef439a43423da42cf738060 100644 (file)
       <compile files="SimpleB.java" options="-14"/>
       <run class="SimpleB"/>
     </ajc-test>
-    
+
     <!-- empty aspect -->
     <ajc-test dir="bugs160/simplejava" title="simple - c">
-      <compile files="SimpleC.java" options="-13"/>
+      <compile files="SimpleC.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- simple before -->
     <ajc-test dir="bugs160/simplejava" title="simple - d">
       <compile files="SimpleD.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- simple itd field -->
     <ajc-test dir="bugs160/simplejava" title="simple - e">
       <compile files="SimpleE.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- aspect with main calling a static method -->
     <ajc-test dir="bugs160/simplejava" title="simple - f">
       <compile files="SimpleF.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- pertarget -->
     <ajc-test dir="bugs160/simplejava" title="simple - g">
       <compile files="SimpleG.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- generic ctor itds -->
     <ajc-test dir="bugs160/simplejava" title="simple - h">
       <compile files="SimpleH.java" options="-14"/>
     </ajc-test>
-    
+
     <!-- overriding generic itd methods -->
     <ajc-test dir="bugs160/simplejava" title="simple - i">
       <compile files="SimpleI.java" options="-14"/>
     </ajc-test>
-    
-    <!-- check class file version is 57.0 -->
+
+    <!-- check class file version is 58.0 (Java 14) -->
     <ajc-test dir="bugs160/simplejava" title="simple - j">
       <compile files="SimpleJ.java" options="-14"/>
     </ajc-test>
 
-    <!-- check class file version is 57.0 -->
+    <!-- check class file version is 58.0 (Java 14) -->
     <ajc-test dir="bugs160/simplejava" title="simple - k">
       <compile files="SimpleJ.java" options="-source 14"/>
     </ajc-test>
 
-    <!-- check class file version is 49.0 -->
+    <!-- check class file version is 49.0 (Java 1.5) -->
     <ajc-test dir="bugs160/simplejava" title="simple - m">
       <compile files="SimpleJ.java" options="-1.5"/>
     </ajc-test>
diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc197/ajc197.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc197/ajc197.xml
new file mode 100644 (file)
index 0000000..6f6edaf
--- /dev/null
@@ -0,0 +1,107 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<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"/>
+               <run class="HiddenClassDemo" classpath="hidden.jar">
+                       <stdout>
+                               <line text="Hidden class name = HiddenClass/" />
+                               <line text="Hidden class canonical name = null" />
+                               <line text="Class.forName resolution error = java.lang.ClassNotFoundException: HiddenClass/" />
+                               <line text="Hello from dynamically defined hidden class" />
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <ajc-test dir="features196/java14" vm="15" title="simple record">
+               <compile files="Person.java" options="--enable-preview -15" />
+       </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">
+                       <stdout>
+                               <line text="Person[firstName=A, lastName=B, age=99]" />
+                               <line text="A" />
+                       </stdout>
+               </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">
+                       <stdout>
+                               <line text="orange" />
+                               <line text="apple" />
+                       </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">
+                       <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" />
+                       </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">
+               </compile>
+               <run class="Code">
+                       <stdout>
+                               <line text="this is a text" />
+                               <line text="block" />
+                       </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">
+               </compile>
+               <run class="Code2">
+                       <stdout>
+                               <line text="this is a text" />
+                               <line text="block in advice" />
+                       </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" />
+       </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">
+                       <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" />
+               <run class="TopManager" vmargs="--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/ajc197/sanity-tests-15.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc197/sanity-tests-15.xml
new file mode 100644 (file)
index 0000000..e43269d
--- /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="-15"/>
+    </ajc-test>
+
+    <!-- class with one method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - b">
+      <compile files="SimpleB.java" options="-15"/>
+      <run class="SimpleB"/>
+    </ajc-test>
+
+    <!-- empty aspect -->
+    <ajc-test dir="bugs160/simplejava" title="simple - c">
+      <compile files="SimpleC.java" options="-15"/>
+    </ajc-test>
+
+    <!-- simple before -->
+    <ajc-test dir="bugs160/simplejava" title="simple - d">
+      <compile files="SimpleD.java" options="-15"/>
+    </ajc-test>
+
+    <!-- simple itd field -->
+    <ajc-test dir="bugs160/simplejava" title="simple - e">
+      <compile files="SimpleE.java" options="-15"/>
+    </ajc-test>
+
+    <!-- aspect with main calling a static method -->
+    <ajc-test dir="bugs160/simplejava" title="simple - f">
+      <compile files="SimpleF.java" options="-15"/>
+    </ajc-test>
+
+    <!-- pertarget -->
+    <ajc-test dir="bugs160/simplejava" title="simple - g">
+      <compile files="SimpleG.java" options="-15"/>
+    </ajc-test>
+
+    <!-- generic ctor itds -->
+    <ajc-test dir="bugs160/simplejava" title="simple - h">
+      <compile files="SimpleH.java" options="-15"/>
+    </ajc-test>
+
+    <!-- overriding generic itd methods -->
+    <ajc-test dir="bugs160/simplejava" title="simple - i">
+      <compile files="SimpleI.java" options="-15"/>
+    </ajc-test>
+
+    <!-- check class file version is 59.0 (Java 15) -->
+    <ajc-test dir="bugs160/simplejava" title="simple - j">
+      <compile files="SimpleJ.java" options="-15"/>
+    </ajc-test>
+
+    <!-- check class file version is 59.0 (Java 15) -->
+    <ajc-test dir="bugs160/simplejava" title="simple - k">
+      <compile files="SimpleJ.java" options="-source 15"/>
+    </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="-15"/>
+    </ajc-test>
+</suite>
index 1f4ee65b4500c33e673c1a064c23ff687c904496..a0535d38932c643d494fec37ea670d82429ff73c 100644 (file)
@@ -182,6 +182,10 @@ public class LangUtil {
                return 15 <= vmVersion;
        }
 
+       public static boolean is16VMOrGreater() {
+               return 16 <= vmVersion;
+       }
+
        /**
         * Shorthand for "if null, throw IllegalArgumentException"
         *