8058855: Update java.util.zip tests to work with modular image

Reviewed-by: dholmes, sherman, alanb
This commit is contained in:
Amy Lu 2014-10-11 13:24:23 +01:00 committed by Alan Bateman
parent 30f7d127ad
commit 9b4793ec4c
2 changed files with 7 additions and 26 deletions
jdk/test/java/util/zip

@ -30,32 +30,14 @@ import java.io.*;
import java.util.zip.*; import java.util.zip.*;
public class InterruptibleZip { public class InterruptibleZip {
private static String rtJar() {
String bcp = System.getProperty("sun.boot.class.path");
for (String pathElement : bcp.split(File.pathSeparator)) {
if (pathElement.endsWith(File.separator + "rt.jar") &&
new File(pathElement).exists()) {
System.out.println("rtJar="+pathElement);
return pathElement;
}
if (pathElement.endsWith(File.separator + "classes") &&
new File(pathElement).isDirectory()) {
System.out.println("rt.jar not available");
return null;
}
}
throw new Error("Can't find rt.jar or classes directory");
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
/* Interrupt the current thread. The is.read call below /* Interrupt the current thread. The is.read call below
should continue reading rt.jar. should continue reading input.jar.
*/ */
String rtJar = rtJar();
if (rtJar == null) return;
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
ZipFile zf = new ZipFile(rtJar); ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.jar"));
ZipEntry ze = zf.getEntry("java/lang/Object.class"); ZipEntry ze = zf.getEntry("Available.java");
InputStream is = zf.getInputStream(ze); InputStream is = zf.getInputStream(ze);
byte[] buf = new byte[512]; byte[] buf = new byte[512];
int n = is.read(buf); int n = is.read(buf);

@ -51,12 +51,11 @@ public class FinalizeZipFile {
private static void makeGarbage() throws Throwable { private static void makeGarbage() throws Throwable {
final Random rnd = new Random(); final Random rnd = new Random();
final String javaHome = System.getProperty("java.home");
// Create some ZipFiles. // Create some ZipFiles.
// Find some .jar files in JDK's lib directory. // Find some .jar files in test directory.
final File lib = new File(javaHome, "lib"); final File testdir = new File(System.getProperty("test.src", "."));
check(lib.isDirectory()); check(testdir.isDirectory());
final File[] jars = lib.listFiles( final File[] jars = testdir.listFiles(
new FilenameFilter() { new FilenameFilter() {
public boolean accept(File dir, String name) { public boolean accept(File dir, String name) {
return name.endsWith(".jar");}}); return name.endsWith(".jar");}});