< prev index next >

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

8217385: JTREG: Clean up, make sure to close resources

20  * questions.                                                                                                              
21  *                                                                                                                         
22  */                                                                                                                        
23 
24 package gc.stress.gcbasher;                                                                                                
25 
26 import java.io.IOException;                                                                                                
27 import java.net.URI;                                                                                                       
28 import java.nio.file.FileSystems;                                                                                          
29 import java.nio.file.FileSystem;                                                                                           
30 import java.nio.file.Files;                                                                                                
31 import java.nio.file.Path;                                                                                                 
32 import java.util.HashMap;                                                                                                  
33 import java.util.stream.Stream;                                                                                            
34 
35 public class TestGCBasher {                                                                                                
36     private static void parseClassFiles() throws IOException {                                                             
37         HashMap<String, ClassInfo> deps = new HashMap<>();                                                                 
38 
39         FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));                                                    
40         Stream<Path> s = Files.walk(fs.getPath("/"));                                                                      
41         for (Path p : (Iterable<Path>)s::iterator) {                                                                       
42             if (p.toString().endsWith(".class") &&                                                                         
43                 !p.getFileName().toString().equals("module-info.class")) {                                                 
44                 byte[] data = Files.readAllBytes(p);                                                                       
45                 Decompiler d = new Decompiler(data);                                                                       
46                 ClassInfo ci = d.getClassInfo();                                                                           
47                 deps.put(ci.getName(), ci);                                                                                
                                                                                                                           
48             }                                                                                                              
49         }                                                                                                                  
50     }                                                                                                                      
51 
52     public static void main(String[] args) throws IOException {                                                            
53         if (args.length != 1) {                                                                                            
54             System.err.println("Usage: TestGCBasher <duration-ms>");                                                       
55             return;                                                                                                        
56         }                                                                                                                  
57 
58         long durationMillis = Long.valueOf(args[0]);                                                                       
59         long start = System.currentTimeMillis();                                                                           
60         while (System.currentTimeMillis() - start < durationMillis) {                                                      
61             parseClassFiles();                                                                                             
62         }                                                                                                                  
63     }                                                                                                                      
64 }                                                                                                                          

20  * questions.
21  *
22  */
23 
24 package gc.stress.gcbasher;
25 
26 import java.io.IOException;
27 import java.net.URI;
28 import java.nio.file.FileSystems;
29 import java.nio.file.FileSystem;
30 import java.nio.file.Files;
31 import java.nio.file.Path;
32 import java.util.HashMap;
33 import java.util.stream.Stream;
34 
35 public class TestGCBasher {
36     private static void parseClassFiles() throws IOException {
37         HashMap<String, ClassInfo> deps = new HashMap<>();
38 
39         FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
40         try (Stream<Path> s = Files.walk(fs.getPath("/"))) {
41             for (Path p : (Iterable<Path>)s::iterator) {
42                 if (p.toString().endsWith(".class") &&
43                     !p.getFileName().toString().equals("module-info.class")) {
44                     byte[] data = Files.readAllBytes(p);
45                     Decompiler d = new Decompiler(data);
46                     ClassInfo ci = d.getClassInfo();
47                     deps.put(ci.getName(), ci);
48                 }
49             }
50         }
51     }
52 
53     public static void main(String[] args) throws IOException {
54         if (args.length != 1) {
55             System.err.println("Usage: TestGCBasher <duration-ms>");
56             return;
57         }
58 
59         long durationMillis = Long.valueOf(args[0]);
60         long start = System.currentTimeMillis();
61         while (System.currentTimeMillis() - start < durationMillis) {
62             parseClassFiles();
63         }
64     }
65 }
< prev index next >