--- old/test/hotspot/jtreg/runtime/appcds/test-classes/Util.java 2017-12-12 16:26:13.358502323 -0800 +++ new/test/hotspot/jtreg/runtime/appcds/test-classes/Util.java 2017-12-12 16:26:12.954487176 -0800 @@ -39,7 +39,7 @@ throws FileNotFoundException, IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { - DataInputStream dis = new DataInputStream(new FileInputStream(clsFile)); + try (DataInputStream dis = new DataInputStream(new FileInputStream(clsFile))) { byte[] buff = new byte[(int)clsFile.length()]; dis.readFully(buff); replace(buff, fromString, toString); @@ -57,6 +57,7 @@ System.out.println("Loaded : " + cls); return cls; + } } /** @@ -146,11 +147,10 @@ JarFile jf = new JarFile(jarFile); JarEntry ent = jf.getJarEntry(className.replace('.', '/') + ".class"); - DataInputStream dis = new DataInputStream(jf.getInputStream(ent)); - byte[] buff = new byte[(int)ent.getSize()]; - dis.readFully(buff); - dis.close(); - - return buff; + try (DataInputStream dis = new DataInputStream(jf.getInputStream(ent))) { + byte[] buff = new byte[(int)ent.getSize()]; + dis.readFully(buff); + return buff; + } } }