+++ /dev/null
-import sun.security.x509.X509CertInfo;
-
-import java.security.cert.CertificateParsingException;
-
-/**
- * https://github.com/mojohaus/aspectj-maven-plugin/issues/139
- */
-public class Application {
- public static void main(String[] args) {
- try {
- new X509CertInfo(new byte[0]);
- }
- catch (CertificateParsingException e) {
- System.out.println(e);
- }
- }
-}
--- /dev/null
+import sun.security.x509.X509CertInfo;
+
+import java.security.cert.CertificateParsingException;
+
+/**
+ * https://github.com/mojohaus/aspectj-maven-plugin/issues/139
+ */
+public class Application {
+ public static void main(String[] args) {
+ try {
+ new X509CertInfo(new byte[0]);
+ }
+ catch (CertificateParsingException e) {
+ System.out.println(e);
+ }
+ }
+}
--- /dev/null
+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");
+ }
+}
--- /dev/null
+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);
+ }
+}
--- /dev/null
+module my.module {
+ //exports my.module;
+}
--- /dev/null
+package my.module;
+
+public class Modular {}
--- /dev/null
+module other.module {
+ exports other.module;
+}
--- /dev/null
+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");
+ }
+}
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);
}
</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>