From 05de3c05c3619c0aacd5b47a80ac1c6767deb39c Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Mon, 11 Dec 2023 09:13:40 +0700 Subject: Add tests for Java 21 unnamed classes and instance methods TODO: Activate the unnamed class test after https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1106 is done. Signed-off-by: Alexander Kriegisch --- .../NamedAspectWithSimpleMainMethodPreview1.aj | 11 ++++++++ .../NamedClassWithSimpleMainMethodPreview1.java | 11 ++++++++ .../UnnamedClassWithSimpleMainMethodPreview1.java | 6 ++++ .../ajc1921/Java21PreviewFeaturesTests.java | 19 +++++++++++++ .../org/aspectj/systemtest/ajc1921/ajc1921.xml | 33 ++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj create mode 100644 tests/features1921/java21/NamedClassWithSimpleMainMethodPreview1.java create mode 100644 tests/features1921/java21/UnnamedClassWithSimpleMainMethodPreview1.java (limited to 'tests') diff --git a/tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj b/tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj new file mode 100644 index 000000000..337f1b9b1 --- /dev/null +++ b/tests/features1921/java21/NamedAspectWithSimpleMainMethodPreview1.aj @@ -0,0 +1,11 @@ +/** + * Example according to JEP 445 + *

+ * 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 index 000000000..d6fced008 --- /dev/null +++ b/tests/features1921/java21/NamedClassWithSimpleMainMethodPreview1.java @@ -0,0 +1,11 @@ +/** + * Example according to JEP 445 + *

+ * 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 index 000000000..a9ecd1d7e --- /dev/null +++ b/tests/features1921/java21/UnnamedClassWithSimpleMainMethodPreview1.java @@ -0,0 +1,6 @@ +/** + * Example according to JEP 445 + */ +void main() { + System.out.println("Hello world!"); +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java index bdde4b67e..79ce4c6cb 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc1921/Java21PreviewFeaturesTests.java @@ -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 GitHub issue 1106. + *

+ * 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); } diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml index edb41fb31..0c31700b2 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc1921/ajc1921.xml @@ -300,4 +300,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3