< prev index next >

test/hotspot/jtreg/serviceability/dcmd/vm/ClassLoaderStatsTest.java

Print this page




 202             throw new RuntimeException("Unexpected exception in TestClass: " + e.getMessage());
 203         }
 204     }
 205 
 206 
 207     static byte[] readClassFile(String classFileName) throws Exception {
 208         File classFile = new File(classFileName);
 209         try (FileInputStream in = new FileInputStream(classFile);
 210              ByteArrayOutputStream out = new ByteArrayOutputStream())
 211         {
 212             int b;
 213             while ((b = in.read()) != -1) {
 214                 out.write(b);
 215             }
 216             return out.toByteArray();
 217         }
 218     }
 219 
 220     static Class<?> defineHiddenClass(byte[] bytes) throws Exception {
 221         Lookup lookup = MethodHandles.lookup();
 222         Class<?> hc = lookup.defineHiddenClass(bytes, false, NESTMATE, WEAK).lookupClass();
 223         return hc;
 224     }
 225 }


 202             throw new RuntimeException("Unexpected exception in TestClass: " + e.getMessage());
 203         }
 204     }
 205 
 206 
 207     static byte[] readClassFile(String classFileName) throws Exception {
 208         File classFile = new File(classFileName);
 209         try (FileInputStream in = new FileInputStream(classFile);
 210              ByteArrayOutputStream out = new ByteArrayOutputStream())
 211         {
 212             int b;
 213             while ((b = in.read()) != -1) {
 214                 out.write(b);
 215             }
 216             return out.toByteArray();
 217         }
 218     }
 219 
 220     static Class<?> defineHiddenClass(byte[] bytes) throws Exception {
 221         Lookup lookup = MethodHandles.lookup();
 222         Class<?> hc = lookup.defineHiddenClass(bytes, false, NESTMATE).lookupClass();
 223         return hc;
 224     }
 225 }
< prev index next >