< prev index next >

test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasher.java

8217385: JTREG: Clean up, make sure to close resources
 public class TestGCBasher {
     private static void parseClassFiles() throws IOException {
         HashMap<String, ClassInfo> deps = new HashMap<>();
 
         FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
-        Stream<Path> s = Files.walk(fs.getPath("/"));
-        for (Path p : (Iterable<Path>)s::iterator) {
-            if (p.toString().endsWith(".class") &&
-                !p.getFileName().toString().equals("module-info.class")) {
-                byte[] data = Files.readAllBytes(p);
-                Decompiler d = new Decompiler(data);
-                ClassInfo ci = d.getClassInfo();
-                deps.put(ci.getName(), ci);
+        try (Stream<Path> s = Files.walk(fs.getPath("/"))) {
+            for (Path p : (Iterable<Path>)s::iterator) {
+                if (p.toString().endsWith(".class") &&
+                    !p.getFileName().toString().equals("module-info.class")) {
+                    byte[] data = Files.readAllBytes(p);
+                    Decompiler d = new Decompiler(data);
+                    ClassInfo ci = d.getClassInfo();
+                    deps.put(ci.getName(), ci);
+                }
             }
         }
     }
 
     public static void main(String[] args) throws IOException {
    
< prev index next >