test/java/util/zip/ZipFile/FinalizeZipFile.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 22,39 ****
*/
/* @test
* @bug 7007609 7009618
* @summary Check that ZipFile objects are always collected
*/
import java.io.*;
- import java.nio.*;
import java.util.Random;
import java.util.zip.*;
import java.util.concurrent.CountDownLatch;
- import java.util.concurrent.TimeUnit;
public class FinalizeZipFile {
private final static CountDownLatch finalizersDone = new CountDownLatch(3);
--- 22,38 ----
*/
/* @test
* @bug 7007609 7009618
* @summary Check that ZipFile objects are always collected
+ * @run main/othervm FinalizeZipFile
*/
import java.io.*;
import java.util.Random;
import java.util.zip.*;
import java.util.concurrent.CountDownLatch;
public class FinalizeZipFile {
private final static CountDownLatch finalizersDone = new CountDownLatch(3);
*** 41,50 ****
--- 40,50 ----
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();
}
*** 79,89 ****
public static void realMain(String[] args) throws Throwable {
makeGarbage();
System.gc();
! finalizersDone.await(5, TimeUnit.SECONDS);
// Not all ZipFiles were collected?
equal(finalizersDone.getCount(), 0L);
}
--- 79,89 ----
public static void realMain(String[] args) throws Throwable {
makeGarbage();
System.gc();
! finalizersDone.await();
// Not all ZipFiles were collected?
equal(finalizersDone.getCount(), 0L);
}