--- old/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java 2017-02-23 15:44:33.000000000 -0800 +++ new/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java 2017-02-23 15:44:33.000000000 -0800 @@ -64,7 +64,7 @@ private static final String MAIN_MID = "m1/p1.Main"; // the names of the modules in this test - private static String[] modules = new String[] {"m1", "m2", "m3", "m4"}; + private static String[] modules = new String[] {"m1", "m2", "m3", "m4", "m5"}; private static boolean hasJmods() { @@ -160,6 +160,50 @@ .getExitValue() == 0); } + @Test + public void testRequiresStatic() throws Throwable { + if (!hasJmods()) return; + + Path dir = Paths.get("requiresStatic"); + createImage(dir, "m5"); + Path java = dir.resolve("bin").resolve("java"); + assertTrue(executeProcess(java.toString(), "-m", "m5/p5.Main") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue() == 0); + + // run with m3 present + assertTrue(executeProcess(java.toString(), + "--module-path", MODS_DIR.toString(), + "--add-modules", "m3", + "-m", "m5/p5.Main") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue() == 0); + } + + @Test + public void testRequiresStatic2() throws Throwable { + if (!hasJmods()) return; + + Path dir = Paths.get("requiresStatic2"); + createImage(dir, "m3", "m5"); + + Path java = dir.resolve("bin").resolve("java"); + assertTrue(executeProcess(java.toString(), "-m", "m5/p5.Main") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue() == 0); + + // boot layer with m3 and m5 + assertTrue(executeProcess(java.toString(), + "--add-modules", "m3", + "-m", "m5/p5.Main") + .outputTo(System.out) + .errorTo(System.out) + .getExitValue() == 0); + } + private void createJmods(String... modules) throws IOException { // use the same target platform as in java.base ModuleDescriptor md = Layer.boot().findModule("java.base").get()