< prev index next >

jdk/test/tools/launcher/modules/dryrun/DryRunTest.java

Print this page

        

*** 24,44 **** /** * @test * @bug 8159596 * @library /lib/testlibrary * @modules jdk.compiler ! * jdk.jartool/sun.tools.jar * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools * @run testng DryRunTest * @summary Test java --dry-run */ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import jdk.testlibrary.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; --- 24,45 ---- /** * @test * @bug 8159596 * @library /lib/testlibrary * @modules jdk.compiler ! * jdk.jartool * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools * @run testng DryRunTest * @summary Test java --dry-run */ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; + import java.util.spi.ToolProvider; import jdk.testlibrary.ProcessTools; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;
*** 76,87 **** "--module-source-path", SRC_DIR.toString())); Files.createDirectories(LIBS_DIR); // create JAR files with no module-info.class ! assertTrue(jar(M_MODULE, "p/Lib.class")); ! assertTrue(jar(TEST_MODULE, "jdk/test/Main.class")); } /** * Execute "java" with the given arguments, returning the exit code. */ --- 77,88 ---- "--module-source-path", SRC_DIR.toString())); Files.createDirectories(LIBS_DIR); // create JAR files with no module-info.class ! assertTrue(jar(M_MODULE, "p/Lib.class") == 0); ! assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0); } /** * Execute "java" with the given arguments, returning the exit code. */
*** 195,214 **** // resolution failure int exitValue = exec("--dry-run", "--module-path", subdir, "-m", mid); assertTrue(exitValue != 0); } ! private static boolean jar(String name, String entries) throws IOException { Path jar = LIBS_DIR.resolve(name + ".jar"); // jar --create ... String classes = MODS_DIR.resolve(name).toString(); String[] args = { "--create", "--file=" + jar, "-C", classes, entries }; ! boolean success ! = new sun.tools.jar.Main(System.out, System.out, "jar").run(args); ! return success; } } --- 196,218 ---- // resolution failure int exitValue = exec("--dry-run", "--module-path", subdir, "-m", mid); assertTrue(exitValue != 0); } ! private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") ! .orElseThrow(() -> ! new RuntimeException("jar tool not found") ! ); ! ! private static int jar(String name, String entries) throws IOException { Path jar = LIBS_DIR.resolve(name + ".jar"); // jar --create ... String classes = MODS_DIR.resolve(name).toString(); String[] args = { "--create", "--file=" + jar, "-C", classes, entries }; ! return JAR_TOOL.run(System.out, System.out, args); } }
< prev index next >