test/java/util/zip/ZipFile/EnumAfterClose.java
Print this page
rev 3516 : 7021582: convert jar/zip code and tests to use try-with-resources
Reviewed-by: XXX
*** 31,44 ****
import java.util.zip.*;
import java.util.Enumeration;
public class EnumAfterClose {
public static void main(String args[]) throws Exception {
! ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
! "input.zip"));
! Enumeration e = zf.entries();
! zf.close();
try {
if (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry)e.nextElement();
}
} catch (IllegalStateException ie) {
--- 31,46 ----
import java.util.zip.*;
import java.util.Enumeration;
public class EnumAfterClose {
public static void main(String args[]) throws Exception {
! Enumeration e;
! try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
! "input.zip"))) {
! e = zf.entries();
! }
! // ensure that the ZipFile is closed before checking the Enumeration
try {
if (e.hasMoreElements()) {
ZipEntry ze = (ZipEntry)e.nextElement();
}
} catch (IllegalStateException ie) {