< prev index next >

jdk/test/tools/jar/UpdateJar.java

Print this page

        

*** 22,42 **** */ /** * @test * @bug 7175845 ! * @modules jdk.jartool/sun.tools.jar * @summary jar -uf should not change file permission */ import java.io.*; import java.nio.file.*; import java.nio.file.attribute.*; import java.util.Set; ! import sun.tools.jar.Main; public class UpdateJar { private static void cleanup(String... fnames) throws Throwable { for (String fname : fnames) { Files.deleteIfExists(Paths.get(fname)); } --- 22,46 ---- */ /** * @test * @bug 7175845 ! * @modules jdk.jartool * @summary jar -uf should not change file permission */ import java.io.*; import java.nio.file.*; import java.nio.file.attribute.*; import java.util.Set; ! import java.util.spi.ToolProvider; public class UpdateJar { + private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); private static void cleanup(String... fnames) throws Throwable { for (String fname : fnames) { Files.deleteIfExists(Paths.get(fname)); }
*** 53,68 **** FileOutputStream fos1 = new FileOutputStream(e1)) { fos0.write(0); fos1.write(0); } String[] jarArgs = new String[] {"cfM0", jar, e0}; ! if (!new Main(System.out, System.err, "jar").run(jarArgs)) { fail("Could not create jar file."); } Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar)); jarArgs = new String[] {"uf", jar, e1}; ! if (!new Main(System.out, System.err, "jar").run(jarArgs)) { fail("Could not create jar file."); } equal(pm, Files.getPosixFilePermissions(Paths.get(jar))); } finally { cleanup(jar, e0, e1); --- 57,72 ---- FileOutputStream fos1 = new FileOutputStream(e1)) { fos0.write(0); fos1.write(0); } String[] jarArgs = new String[] {"cfM0", jar, e0}; ! if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) { fail("Could not create jar file."); } Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar)); jarArgs = new String[] {"uf", jar, e1}; ! if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) { fail("Could not create jar file."); } equal(pm, Files.getPosixFilePermissions(Paths.get(jar))); } finally { cleanup(jar, e0, e1);
< prev index next >