From 417a0224e5f585850593ebac55b6083636a25fd9 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Thu, 31 Mar 2022 11:31:20 +0700 Subject: [PATCH] Add some smoke test cases for '--add-reads' and '--add-modules' in order to show that the compiler options basically work. The test cases are by no means exhaustive and simply verify that it works at all. Signed-off-by: Alexander Kriegisch --- .../add_exports/Application.java | 0 .../github_145/add_modules/NonModular.java | 9 +++ .../add_modules/UseJDKExtendedCharsets.java | 17 +++++ .../add_modules/my.module/module-info.java | 3 + .../my.module/my/module/Modular.java | 3 + .../add_reads/other.module/module-info.java | 3 + .../other/module/Application.java | 15 ++++ .../systemtest/ajc199/Bugs199Tests.java | 14 +++- .../org/aspectj/systemtest/ajc199/ajc199.xml | 69 ++++++++++++++++++- 9 files changed, 129 insertions(+), 4 deletions(-) rename tests/bugs199/{ => github_145}/add_exports/Application.java (100%) create mode 100644 tests/bugs199/github_145/add_modules/NonModular.java create mode 100644 tests/bugs199/github_145/add_modules/UseJDKExtendedCharsets.java create mode 100644 tests/bugs199/github_145/add_modules/my.module/module-info.java create mode 100644 tests/bugs199/github_145/add_modules/my.module/my/module/Modular.java create mode 100644 tests/bugs199/github_145/add_reads/other.module/module-info.java create mode 100644 tests/bugs199/github_145/add_reads/other.module/other/module/Application.java diff --git a/tests/bugs199/add_exports/Application.java b/tests/bugs199/github_145/add_exports/Application.java similarity index 100% rename from tests/bugs199/add_exports/Application.java rename to tests/bugs199/github_145/add_exports/Application.java diff --git a/tests/bugs199/github_145/add_modules/NonModular.java b/tests/bugs199/github_145/add_modules/NonModular.java new file mode 100644 index 000000000..6bdaffa06 --- /dev/null +++ b/tests/bugs199/github_145/add_modules/NonModular.java @@ -0,0 +1,9 @@ +import my.module.Modular; + +public class NonModular { + Modular modular = new Modular(); + + public static void main(String[] args) { + System.out.println("Non-modular class can use modular one"); + } +} diff --git a/tests/bugs199/github_145/add_modules/UseJDKExtendedCharsets.java b/tests/bugs199/github_145/add_modules/UseJDKExtendedCharsets.java new file mode 100644 index 000000000..423d564a8 --- /dev/null +++ b/tests/bugs199/github_145/add_modules/UseJDKExtendedCharsets.java @@ -0,0 +1,17 @@ +import java.nio.charset.Charset; +import sun.nio.cs.ext.ExtendedCharsets; + +public class UseJDKExtendedCharsets { + static ExtendedCharsets charsets = new ExtendedCharsets(); + static Charset iso2022jp = charsets.charsetForName("ISO-2022-JP"); + static Charset jis = charsets.charsetForName("jis"); + static Charset jis_encoding = charsets.charsetForName("jis_encoding"); + + public static void main(String[] args) { + // The 3 charsets are aliases of each other + assert iso2022jp != null; + System.out.println(iso2022jp); + assert iso2022jp.equals(jis); + assert iso2022jp.equals(jis_encoding); + } +} diff --git a/tests/bugs199/github_145/add_modules/my.module/module-info.java b/tests/bugs199/github_145/add_modules/my.module/module-info.java new file mode 100644 index 000000000..beee5b586 --- /dev/null +++ b/tests/bugs199/github_145/add_modules/my.module/module-info.java @@ -0,0 +1,3 @@ +module my.module { + //exports my.module; +} diff --git a/tests/bugs199/github_145/add_modules/my.module/my/module/Modular.java b/tests/bugs199/github_145/add_modules/my.module/my/module/Modular.java new file mode 100644 index 000000000..febc7f821 --- /dev/null +++ b/tests/bugs199/github_145/add_modules/my.module/my/module/Modular.java @@ -0,0 +1,3 @@ +package my.module; + +public class Modular {} diff --git a/tests/bugs199/github_145/add_reads/other.module/module-info.java b/tests/bugs199/github_145/add_reads/other.module/module-info.java new file mode 100644 index 000000000..3cc4823e7 --- /dev/null +++ b/tests/bugs199/github_145/add_reads/other.module/module-info.java @@ -0,0 +1,3 @@ +module other.module { + exports other.module; +} diff --git a/tests/bugs199/github_145/add_reads/other.module/other/module/Application.java b/tests/bugs199/github_145/add_reads/other.module/other/module/Application.java new file mode 100644 index 000000000..ff299017e --- /dev/null +++ b/tests/bugs199/github_145/add_reads/other.module/other/module/Application.java @@ -0,0 +1,15 @@ +package other.module; + +import java.util.ArrayList; +import java.util.List; + +import my.module.Modular; + +public class Application { + List list = new ArrayList<>(); + Modular modular = new Modular(); + + public static void main(String[] args) { + System.out.println("One modular class can use another one"); + } +} diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java index a9f7f3023..5b2087ed2 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java @@ -61,10 +61,22 @@ public class Bugs199Tests extends XMLBasedAjcTestCase { runTest("asynchronous proceed for nested around-advice (native, thread pool)"); } - public void testAddExports() { + public void testAddExports_gh145() { runTest("use --add-exports"); } + public void testAddReads_gh145() { + runTest("use --add-reads"); + } + + public void testAddModules_gh145() { + runTest("use --add-modules"); + } + + public void testAddModulesJDK_gh145() { + runTest("use --add-modules with non-public JDK module"); + } + public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Bugs199Tests.class); } diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml index 9a9ac2d47..7c38db68e 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml @@ -515,13 +515,76 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.5