< prev index next >

jdk/test/tools/jar/JarEntryTime.java

Print this page

        

*** 22,43 **** */ /** * @test * @bug 4225317 6969651 ! * @modules jdk.jartool/sun.tools.jar * @summary Check extracted files have date as per those in the .jar file */ import java.io.File; import java.io.PrintWriter; import java.nio.file.attribute.FileTime; import java.util.Date; import java.util.TimeZone; ! import sun.tools.jar.Main; public class JarEntryTime { // ZipEntry's mod date has 2 seconds precision: give extra time to // allow for e.g. rounding/truncation and networked/samba drives. static final long PRECISION = 10000L; --- 22,48 ---- */ /** * @test * @bug 4225317 6969651 ! * @modules jdk.jartool * @summary Check extracted files have date as per those in the .jar file */ import java.io.File; import java.io.PrintWriter; import java.nio.file.attribute.FileTime; import java.util.Date; import java.util.TimeZone; ! import java.util.spi.ToolProvider; public class JarEntryTime { + static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar") + .orElseThrow(() -> + new RuntimeException("jar tool not found") + ); + // ZipEntry's mod date has 2 seconds precision: give extra time to // allow for e.g. rounding/truncation and networked/samba drives. static final long PRECISION = 10000L;
*** 112,125 **** check(dirOuter.setLastModified(now)); check(dirInner.setLastModified(yesterday)); check(fileInner.setLastModified(earlier)); // Make a jar file from that directory structure ! Main jartool = new Main(System.out, System.err, "jar"); ! check(jartool.run(new String[] { ! "cf", ! jarFile.getName(), dirOuter.getName() } )); check(jarFile.exists()); check(cleanup(dirInner)); check(cleanup(dirOuter)); --- 117,128 ---- check(dirOuter.setLastModified(now)); check(dirInner.setLastModified(yesterday)); check(fileInner.setLastModified(earlier)); // Make a jar file from that directory structure ! check(JAR_TOOL.run(System.out, System.err, ! "cf", jarFile.getName(), dirOuter.getName()) == 0); check(jarFile.exists()); check(cleanup(dirInner)); check(cleanup(dirOuter));
*** 140,150 **** pw.println("hello, world"); } final long start = testFile.lastModified(); // Extract and check the last modified values are the current times. - // See sun.tools.jar.Main extractJar(jarFile, true); try (PrintWriter pw = new PrintWriter(testFile)) { pw.println("hello, world"); } --- 143,152 ----
< prev index next >