--- old/test/hotspot/jtreg/runtime/appcds/MoveJDKTest.java 2018-07-09 09:52:28.858224621 -0700 +++ new/test/hotspot/jtreg/runtime/appcds/MoveJDKTest.java 2018-07-09 09:52:28.499190734 -0700 @@ -108,6 +108,16 @@ out.shouldNotContain("shared class paths mismatch"); out.shouldNotContain("BOOT classpath mismatch"); } + + // Test with no modules image in the /lib directory + renameModulesFile(java_home_dst); + { + ProcessBuilder pb = makeBuilder(java_home_dst + "/bin/java", + "-version"); + OutputAnalyzer out = TestCommon.executeAndLog(pb, "exec-missing-modules"); + out.shouldHaveExitValue(1); + out.shouldContain("System boot class path should not be NULL"); + } } // Do a cheap clone of the JDK. Most files can be sym-linked. However, $JAVA_HOME/bin/java and $JAVA_HOME/lib/.../libjvm.so" @@ -144,6 +154,24 @@ } } + static void renameModulesFile(String javaHome) throws Exception { + String modulesDir = javaHome + File.separator + "lib"; + File origModules = new File(modulesDir, "modules"); + if (!origModules.exists()) { + throw new RuntimeException("modules file not found"); + } + + File renamedModules = new File(modulesDir, "orig_modules"); + if (renamedModules.exists()) { + throw new RuntimeException("found orig_modules unexpectedly"); + } + + boolean success = origModules.renameTo(renamedModules); + if (!success) { + throw new RuntimeException("rename modules file failed"); + } + } + static ProcessBuilder makeBuilder(String... args) throws Exception { System.out.print("["); for (String s : args) {