< prev index next >

test/tools/jar/ChangeDir.java

Print this page

        

@@ -22,22 +22,25 @@
  */
 
 /**
  * @test
  * @bug 4806786 8023113
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
  * @summary jar -C doesn't ignore multiple // in path
  */
 
 import java.io.*;
 import java.nio.file.*;
 import java.util.*;
 import java.util.jar.*;
+import java.util.spi.ToolProvider;
 import java.util.stream.Stream;
-import sun.tools.jar.Main;
 
 public class ChangeDir {
+    private static final ToolProvider JAR_TOOL =
+        ToolProvider.findFirst("jar").get();
+
     private final static String jarName = "test.jar";
     private final static String fileName = "hello.txt";
 
     /** Remove dirs & files needed for test. */
     private static void cleanup(Path dir) {

@@ -86,12 +89,13 @@
             argList.add(jarName);
             argList.add("-C");
             argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional
             argList.add(fileName);
 
-            Main jarTool = new Main(System.out, System.err, "jar");
-            if (!jarTool.run(argList.toArray(new String[argList.size()]))) {
+            int rc = JAR_TOOL.run(System.out, System.err,
+                                  argList.toArray(new String[argList.size()]));
+            if (rc != 0) {
                 fail("Could not create jar file.");
             }
 
             // Check that the entry for hello.txt does *not* have a pathname.
             try (JarFile jf = new JarFile(jarName)) {
< prev index next >