< prev index next >
test/jdk/tools/launcher/modules/addexports/AddExportsTest.java
Print this page
@@ -22,11 +22,12 @@
*/
/**
* @test
* @library /test/lib
- * @modules jdk.compiler
+ * @modules java.compiler
+ * jdk.compiler
* @build AddExportsTest jdk.test.lib.compiler.CompilerUtils
* @run testng AddExportsTest
* @summary Basic tests for java --add-exports
*/
@@ -49,16 +50,19 @@
private static final String TEST_SRC = System.getProperty("test.src");
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
private static final Path MODS_DIR = Paths.get("mods");
+ private static final Path UPGRADE_MODS_DIRS = Paths.get("upgrademods");
// test module m1 that uses Unsafe
private static final String TEST1_MODULE = "m1";
private static final String TEST1_MAIN_CLASS = "jdk.test1.Main";
-
+ // test module m2 uses java.compiler internals
+ private static final String TEST2_MODULE = "m2";
+ private static final String TEST2_MAIN_CLASS = "jdk.test2.Main";
// test module m3 uses m4 internals
private static final String TEST3_MODULE = "m3";
private static final String TEST3_MAIN_CLASS = "jdk.test3.Main";
private static final String TEST4_MODULE = "m4";
@@ -72,11 +76,23 @@
SRC_DIR.resolve(TEST1_MODULE),
MODS_DIR.resolve(TEST1_MODULE),
"--add-exports", "java.base/jdk.internal.misc=m1");
assertTrue(compiled, "module " + TEST1_MODULE + " did not compile");
+ // javac -d upgrademods/java.compiler src/java.compiler/**
+ compiled = CompilerUtils.compile(
+ SRC_DIR.resolve("java.compiler"),
+ UPGRADE_MODS_DIRS.resolve("java.compiler"));
+ assertTrue(compiled, "module java.compiler did not compile");
+ // javac --upgrade-module-path upgrademods -d mods/m2 src/m2/**
+ compiled = CompilerUtils.compile(
+ SRC_DIR.resolve(TEST2_MODULE),
+ MODS_DIR.resolve(TEST2_MODULE),
+ "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+ "--add-exports", "java.compiler/javax.tools.internal=m2");
+ assertTrue(compiled, "module " + TEST2_MODULE + " did not compile");
// javac -d mods/m3 src/m3/**
compiled = CompilerUtils.compile(
SRC_DIR.resolve(TEST3_MODULE),
MODS_DIR.resolve(TEST3_MODULE));
@@ -144,11 +160,29 @@
.getExitValue();
assertTrue(exitValue == 0);
}
+ /**
+ * Test --add-exports with upgraded module
+ */
+ public void testWithUpgradedModule() throws Exception {
+
+ // java --add-exports java.compiler/javax.tools.internal=m2
+ // --upgrade-module-path upgrademods --module-path mods -m ...
+ String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS;
+ int exitValue = executeTestJava(
+ "--add-exports", "java.compiler/javax.tools.internal=m2",
+ "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(),
+ "--module-path", MODS_DIR.toString(),
+ "-m", mid)
+ .outputTo(System.out)
+ .errorTo(System.out)
+ .getExitValue();
+ assertTrue(exitValue == 0);
+ }
/**
* Test --add-exports with module that is added to the set of root modules
* with --add-modules.
*/
< prev index next >