< prev index next >
test/tools/jar/InputFilesTest.java
Print this page
@@ -27,11 +27,11 @@
* @summary test several jar tool input file scenarios with variations on -C
* options with/without a --release option. Some input files are
* duplicates that sometimes cause exceptions and other times do not,
* demonstrating identical behavior to JDK 8 jar tool.
* @library /lib/testlibrary
- * @modules jdk.jartool/sun.tools.jar
+ * @modules jdk.jartool
* @build jdk.testlibrary.FileUtils
* @run testng InputFilesTest
*/
import org.testng.Assert;
@@ -45,16 +45,20 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
+import java.util.spi.ToolProvider;
import java.util.stream.Stream;
import java.util.zip.ZipException;
import jdk.testlibrary.FileUtils;
public class InputFilesTest {
+ private static final ToolProvider JAR_TOOL =
+ ToolProvider.findFirst("jar").get();
+
private final String nl = System.lineSeparator();
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
private final PrintStream out = new PrintStream(baos);
private Runnable onCompletion;
@@ -193,13 +197,13 @@
// the run method catches IOExceptions, we need to expose them
ByteArrayOutputStream baes = new ByteArrayOutputStream();
PrintStream err = new PrintStream(baes);
PrintStream saveErr = System.err;
System.setErr(err);
- boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +"));
+ int rc = JAR_TOOL.run(out, err, cmdline.split(" +"));
System.setErr(saveErr);
- if (!ok) {
+ if (rc != 0) {
String s = baes.toString();
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
throw new ZipException(s);
}
throw new IOException(s);
< prev index next >