< prev index next >
jdk/test/tools/jar/JarBackSlash.java
Print this page
@@ -26,11 +26,11 @@
*/
/*
* @test
* @bug 7201156
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @summary jar tool fails to convert file separation characters for list and extract
* @author Sean Chou
*/
import java.io.File;
@@ -41,14 +41,17 @@
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
-
-import sun.tools.jar.Main;
+import java.util.spi.ToolProvider;
public class JarBackSlash {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+ .orElseThrow(() ->
+ new RuntimeException("jar tool not found")
+ );
// used construct an entry JarBackSlash/dir/file.txt
private static String JARBACKSLASH = "JarBackSlash";
private static String DIR = "dir";
private static String FILENAME = "file.txt";
@@ -76,12 +79,12 @@
PipedOutputStream pipedOutput = new PipedOutputStream();
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
PrintStream out = new PrintStream(pipedOutput);
- Main jarTool = new Main(out, System.err, "jar");
- if (!jarTool.run(jarArgs)) {
+ int rc = JAR_TOOL.run(out, System.err, jarArgs);
+ if (rc != 0) {
fail("Could not list jar file.");
}
out.flush();
check(pipedInput.available() > 0);
@@ -99,12 +102,12 @@
PipedOutputStream pipedOutput = new PipedOutputStream();
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
PrintStream out = new PrintStream(pipedOutput);
- Main jarTool = new Main(out, System.err, "jar");
- if (!jarTool.run(jarArgs)) {
+ int rc = JAR_TOOL.run(out, System.err, jarArgs);
+ if (rc != 0) {
fail("Could not list jar file.");
}
out.flush();
check(pipedInput.available() > 0);
< prev index next >