]> source.dussan.org Git - aspectj.git/commitdiff
Add tests for Java 21 unnamed classes and instance methods
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 11 Dec 2023 02:13:40 +0000 (09:13 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Mon, 11 Dec 2023 02:38:37 +0000 (03:38 +0100)
TODO: Activate the unnamed class test after
https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106 is done.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj [new file with mode: 0644]
tests/features1921/java21/NamedClassWithSimpleMainMethodPreview1.java [new file with mode: 0644]
tests/features1921/java21/UnnamedClassWithSimpleMainMethodPreview1.java [new file with mode: 0644]
tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java
tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml

diff --git a/tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj b/tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj
new file mode 100644 (file)
index 0000000..337f1b9
--- /dev/null
@@ -0,0 +1,11 @@
+/**
+ * Example according to <a href="https://openjdk.org/jeps/445">JEP 445</a>
+ * <p>
+ * This actually does not require any compiler changes and should be compilable without {@code --enable-preview}.
+ * It merely serves as a test case for the JVM launcher protocol.
+ */
+public aspect NamedAspectWithSimpleMainMethodPreview1 {
+  void main() {
+    System.out.println("Hello world!");
+  }
+}
diff --git a/tests/features1921/java21/NamedClassWithSimpleMainMethodPreview1.java b/tests/features1921/java21/NamedClassWithSimpleMainMethodPreview1.java
new file mode 100644 (file)
index 0000000..d6fced0
--- /dev/null
@@ -0,0 +1,11 @@
+/**
+ * Example according to <a href="https://openjdk.org/jeps/445">JEP 445</a>
+ * <p>
+ * This actually does not require any compiler changes and should be compilable without {@code --enable-preview}.
+ * It merely serves as a test case for the JVM launcher protocol.
+ */
+public class NamedClassWithSimpleMainMethodPreview1 {
+  void main() {
+    System.out.println("Hello world!");
+  }
+}
diff --git a/tests/features1921/java21/UnnamedClassWithSimpleMainMethodPreview1.java b/tests/features1921/java21/UnnamedClassWithSimpleMainMethodPreview1.java
new file mode 100644 (file)
index 0000000..a9ecd1d
--- /dev/null
@@ -0,0 +1,6 @@
+/**
+ * Example according to <a href="https://openjdk.org/jeps/445">JEP 445</a>
+ */
+void main() {
+  System.out.println("Hello world!");
+}
index bdde4b67e15fc376b9fb1ca87b53228593cc82f0..79ce4c6cbe4958b9bc9906c188f6cb222fe1a0d4 100644 (file)
@@ -46,6 +46,25 @@ public class Java21PreviewFeaturesTests extends XMLBasedAjcTestCaseForJava21Only
     System.out.println("Unnamed patterns still are not implemented with the Java 21 release Eclipse 2023-12 (4.30)");
   }
 
+  public void testNamedClassWithSimpleMainMethod() {
+    runTest("named class with simple main method");
+  }
+
+  public void testNamedAspectWithSimpleMainMethod() {
+    runTest("named aspect with simple main method");
+  }
+
+  /**
+   * Still not implemented with the Java 21 release Eclipse 2023-12 (4.30),
+   * see <a href="https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106">GitHub issue 1106</a>.
+   * <p>
+   * TODO: Activate after JDT Core implementation and merge.
+   */
+  public void testUnnamedClassWithSimpleMainMethod() {
+    //runTest("unnamed class with simple main method");
+    System.out.println("Unnamed classes still are not implemented with the Java 21 release Eclipse 2023-12 (4.30)");
+  }
+
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Java21PreviewFeaturesTests.class);
   }
index edb41fb31419d39d3d9485f19981ff76538c96cc..0c31700b2339ec1a4b566a57371f9804b0dec812 100644 (file)
                </run>
        </ajc-test>
 
+       <!-- Java 21 preview -->
+       <ajc-test dir="features1921/java21" vm="21" title="named class with simple main method">
+               <!-- Compiles without preview mode, but needs preview mode to run -->
+               <compile files="NamedClassWithSimpleMainMethodPreview1.java" options="-21"/>
+               <run class="NamedClassWithSimpleMainMethodPreview1" vmargs="--enable-preview">
+                       <stdout>
+                               <line text="Hello world!"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <!-- Java 21 preview -->
+       <ajc-test dir="features1921/java21" vm="21" title="named aspect with simple main method">
+               <!-- Compiles without preview mode, but needs preview mode to run -->
+               <compile files="NamedAspectWithSimpleMainMethodPreview1.aj" options="-21"/>
+               <run class="NamedAspectWithSimpleMainMethodPreview1" vmargs="--enable-preview">
+                       <stdout>
+                               <line text="Hello world!"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
+       <!-- Java 21 preview -->
+       <!-- TODO: Activate after https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106 is done -->
+       <ajc-test dir="features1921/java21" vm="21" title="unnamed class with simple main method">
+               <compile files="UnnamedClassWithSimpleMainMethodPreview1.java" options="--enable-preview -21"/>
+               <run class="UnnamedClassWithSimpleMainMethodPreview1" vmargs="--enable-preview">
+                       <stdout>
+                               <line text="Hello world!"/>
+                       </stdout>
+               </run>
+       </ajc-test>
+
 </suite>