89 runJlink(image, modName); 90 execute(image, modName); 91 } 92 93 private void execute(Path image, String moduleName) throws Throwable { 94 String cmd = image.resolve("bin").resolve(moduleName).toString(); 95 OutputAnalyzer analyzer; 96 if (System.getProperty("os.name").startsWith("Windows")) { 97 analyzer = ProcessTools.executeProcess("sh.exe", cmd, "1", "2", "3"); 98 } else { 99 analyzer = ProcessTools.executeProcess(cmd, "1", "2", "3"); 100 } 101 if (analyzer.getExitValue() != 0) { 102 throw new AssertionError("Image invocation failed: rc=" + analyzer.getExitValue()); 103 } 104 } 105 106 private void runJlink(Path image, String modName, String... options) { 107 List<String> args = new ArrayList<>(); 108 Collections.addAll(args, 109 "--modulepath", jdkMods + File.pathSeparator + jmods, 110 "--addmods", modName, 111 "--output", image.toString()); 112 Collections.addAll(args, options); 113 int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out)); 114 if (rc != 0) { 115 throw new AssertionError("Jlink failed: rc = " + rc); 116 } 117 } 118 119 private void runJmod(String cp, String modName) { 120 int rc = jdk.tools.jmod.Main.run(new String[] { 121 "create", 122 "--class-path", cp, 123 "--module-version", "1.0", 124 "--main-class", "jdk.test.Test", 125 jmods.resolve(modName + ".jmod").toString(), 126 }, System.out); 127 if (rc != 0) { 128 throw new AssertionError("Jmod failed: rc = " + rc); 129 } 130 } | 89 runJlink(image, modName); 90 execute(image, modName); 91 } 92 93 private void execute(Path image, String moduleName) throws Throwable { 94 String cmd = image.resolve("bin").resolve(moduleName).toString(); 95 OutputAnalyzer analyzer; 96 if (System.getProperty("os.name").startsWith("Windows")) { 97 analyzer = ProcessTools.executeProcess("sh.exe", cmd, "1", "2", "3"); 98 } else { 99 analyzer = ProcessTools.executeProcess(cmd, "1", "2", "3"); 100 } 101 if (analyzer.getExitValue() != 0) { 102 throw new AssertionError("Image invocation failed: rc=" + analyzer.getExitValue()); 103 } 104 } 105 106 private void runJlink(Path image, String modName, String... options) { 107 List<String> args = new ArrayList<>(); 108 Collections.addAll(args, 109 "--module-path", jdkMods + File.pathSeparator + jmods, 110 "--add-modules", modName, 111 "--output", image.toString()); 112 Collections.addAll(args, options); 113 int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out)); 114 if (rc != 0) { 115 throw new AssertionError("Jlink failed: rc = " + rc); 116 } 117 } 118 119 private void runJmod(String cp, String modName) { 120 int rc = jdk.tools.jmod.Main.run(new String[] { 121 "create", 122 "--class-path", cp, 123 "--module-version", "1.0", 124 "--main-class", "jdk.test.Test", 125 jmods.resolve(modName + ".jmod").toString(), 126 }, System.out); 127 if (rc != 0) { 128 throw new AssertionError("Jmod failed: rc = " + rc); 129 } 130 } |