--- old/test/java/util/jar/JarEntry/GetMethodsReturnClones.java 2011-02-23 19:49:44.051860892 -0800 +++ new/test/java/util/jar/JarEntry/GetMethodsReturnClones.java 2011-02-23 19:49:43.723738942 -0800 @@ -40,22 +40,21 @@ System.getProperty("file.separator"); public static void main(String[] args) throws Exception { - JarFile jf = new JarFile(BASE + "test.jar", true); - - byte[] buffer = new byte[8192]; - Enumeration e = jf.entries(); List entries = new ArrayList(); - while (e.hasMoreElements()) { - JarEntry je = e.nextElement(); - entries.add(je); - InputStream is = jf.getInputStream(je); - while (is.read(buffer, 0, buffer.length) != -1) { - // we just read. this will throw a SecurityException - // if a signature/digest check fails. + try (JarFile jf = new JarFile(BASE + "test.jar", true)) { + byte[] buffer = new byte[8192]; + Enumeration e = jf.entries(); + while (e.hasMoreElements()) { + JarEntry je = e.nextElement(); + entries.add(je); + try (InputStream is = jf.getInputStream(je)) { + while (is.read(buffer, 0, buffer.length) != -1) { + // we just read. this will throw a SecurityException + // if a signature/digest check fails. + } + } } - is.close(); } - jf.close(); for (JarEntry je : entries) { Certificate[] certs = je.getCertificates();