< prev index next >
test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java
Print this page
*** 29,38 ****
--- 29,39 ----
import java.io.*;
import java.util.Random;
import java.util.zip.*;
import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.TimeUnit;
public class FinalizeZipFile {
private static final CountDownLatch finalizersDone = new CountDownLatch(3);
*** 41,51 ****
public InstrumentedZipFile(File f) throws Exception {
super(f);
System.out.printf("Using %s%n", f.getPath());
}
@Override
! protected void finalize() throws IOException {
System.out.printf("Killing %s%n", getName());
super.finalize();
finalizersDone.countDown();
}
}
--- 42,52 ----
public InstrumentedZipFile(File f) throws Exception {
super(f);
System.out.printf("Using %s%n", f.getPath());
}
@Override
! protected void finalize() throws Throwable {
System.out.printf("Killing %s%n", getName());
super.finalize();
finalizersDone.countDown();
}
}
*** 76,89 ****
}
}
public static void realMain(String[] args) throws Throwable {
makeGarbage();
!
System.gc();
! finalizersDone.await();
!
// Not all ZipFiles were collected?
equal(finalizersDone.getCount(), 0L);
}
//--------------------- Infrastructure ---------------------------
--- 77,89 ----
}
}
public static void realMain(String[] args) throws Throwable {
makeGarbage();
! while (!finalizersDone.await(10, TimeUnit.MILLISECONDS)) {
System.gc();
! }
// Not all ZipFiles were collected?
equal(finalizersDone.getCount(), 0L);
}
//--------------------- Infrastructure ---------------------------
< prev index next >