diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-31 11:31:20 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2022-03-31 14:14:45 +0700 |
commit | 417a0224e5f585850593ebac55b6083636a25fd9 (patch) | |
tree | a24de06e55c3e1c5c56bf515be924f9d73591cea | |
parent | 35e93cf9dfc51aa8b47bc798c375b0ee01e24d42 (diff) | |
download | aspectj-417a0224e5f585850593ebac55b6083636a25fd9.tar.gz aspectj-417a0224e5f585850593ebac55b6083636a25fd9.zip |
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 <Alexander@Kriegisch.name>
-rw-r--r-- | tests/bugs199/github_145/add_exports/Application.java (renamed from tests/bugs199/add_exports/Application.java) | 0 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_modules/NonModular.java | 9 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_modules/UseJDKExtendedCharsets.java | 17 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_modules/my.module/module-info.java | 3 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_modules/my.module/my/module/Modular.java | 3 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_reads/other.module/module-info.java | 3 | ||||
-rw-r--r-- | tests/bugs199/github_145/add_reads/other.module/other/module/Application.java | 15 | ||||
-rw-r--r-- | tests/src/test/java/org/aspectj/systemtest/ajc199/Bugs199Tests.java | 14 | ||||
-rw-r--r-- | tests/src/test/resources/org/aspectj/systemtest/ajc199/ajc199.xml | 69 |
9 files changed, 129 insertions, 4 deletions
diff --git a/tests/bugs199/add_exports/Application.java b/tests/bugs199/github_145/add_exports/Application.java index 88bd177aa..88bd177aa 100644 --- a/tests/bugs199/add_exports/Application.java +++ b/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<String> 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 @@ </run> </ajc-test> - <ajc-test dir="bugs199/add_exports" title="use --add-exports" vm="9"> - <compile files="Application.java" options="-11 --add-exports java.base/sun.security.x509=ALL-UNNAMED" /> - <run class="Application" vmargs="--add-exports java.base/sun.security.x509=ALL-UNNAMED"> + <ajc-test dir="bugs199/github_145/add_exports" title="use --add-exports" vm="9"> + <compile + files="Application.java" + options="-9 --add-exports java.base/sun.security.x509=ALL-UNNAMED" + /> + <run + class="Application" + vmargs="--add-exports java.base/sun.security.x509=ALL-UNNAMED" + > <stdout> <line text="java.security.cert.CertificateParsingException: java.io.IOException"/> </stdout> </run> </ajc-test> + <ajc-test dir="bugs199/github_145" title="use --add-reads" vm="9"> + <compile + files="add_modules/my.module/module-info.java add_modules/my.module/my/module/Modular.java" + options="-9" + outjar="my.module.jar" + /> + <compile + files="add_reads/other.module/module-info.java add_reads/other.module/other/module/Application.java" + options="-9 --add-reads other.module=my.module --add-exports my.module/my.module=other.module" + modulepath="$sandbox/my.module.jar" + outjar="other.module.jar" + /> + <run + class="other.module.Application" + vmargs="--add-reads other.module=my.module" + modulepath="$sandbox/my.module.jar:$sandbox/other.module.jar" + > + <stdout> + <line text="One modular class can use another one"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_145/add_modules" title="use --add-modules" vm="9"> + <compile + files="my.module/module-info.java my.module/my/module/Modular.java" + options="-9" + outjar="my.module.jar" + /> + <compile + files="NonModular.java" + options="-9 --add-modules my.module --add-exports my.module/my.module=ALL-UNNAMED" + modulepath="$sandbox/my.module.jar" + /> + <run class="NonModular" modulepath="$sandbox/my.module.jar"> + <stdout> + <line text="Non-modular class can use modular one"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs199/github_145/add_modules" title="use --add-modules with non-public JDK module" vm="9"> + <!-- + Javac, AJC: no errors. ECJ: "invalid module name: jdk.charsets" + + This is because ECJ does not add internal JDK modules as root modules, but AJC does. This was not so much + intentional in AJC, but simply due to the hacky implementation. Anyway, it works and makes AJC more + Javac-compliant than ECJ, which is nice. + --> + <compile files="UseJDKExtendedCharsets.java" options="-9 --add-modules jdk.charsets --add-exports jdk.charsets/sun.nio.cs.ext=ALL-UNNAMED" /> + <run class="UseJDKExtendedCharsets" vmargs="-ea --add-modules jdk.charsets --add-exports jdk.charsets/sun.nio.cs.ext=ALL-UNNAMED"> + <stdout> + <line text="ISO-2022-JP"/> + </stdout> + </run> + </ajc-test> + </suite> |