< prev index next >

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

Print this page

        

@@ -24,21 +24,22 @@
 /**
  * @test
  * @bug 8159596
  * @library /lib/testlibrary
  * @modules jdk.compiler
- *          jdk.jartool/sun.tools.jar
+ *          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,12 +77,12 @@
                                          "--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"));
+        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,20 +196,20 @@
         // 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 {
+    private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar").get();
+
+    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
         };
-        boolean success
-            = new sun.tools.jar.Main(System.out, System.out, "jar").run(args);
-        return success;
+        return JAR_TOOL.run(System.out, System.out, args);
     }
 }
< prev index next >