55 return c; 56 } 57 58 static byte[] readClassFile(String name) { 59 try { 60 String rname = name.substring(name.lastIndexOf('.') + 1) + ".class"; 61 java.net.URL url = VictimClassLoader.class.getResource(rname); 62 Test8003720.println("found " + rname + " = " + url); 63 64 java.net.URLConnection connection = url.openConnection(); 65 int contentLength = connection.getContentLength(); 66 byte[] buf = readFully(connection.getInputStream(), contentLength); 67 68 return Asmator.fixup(buf); 69 } catch (java.io.IOException ex) { 70 throw new Error(ex); 71 } 72 } 73 74 static byte[] readFully(java.io.InputStream in, int len) throws java.io.IOException { 75 // Warning here: 76 return sun.misc.IOUtils.readFully(in, len, true); 77 } 78 79 public void finalize() { 80 Test8003720.println("Goodbye from " + this); 81 } 82 83 public String toString() { 84 return "VictimClassLoader#" + which; 85 } 86 } | 55 return c; 56 } 57 58 static byte[] readClassFile(String name) { 59 try { 60 String rname = name.substring(name.lastIndexOf('.') + 1) + ".class"; 61 java.net.URL url = VictimClassLoader.class.getResource(rname); 62 Test8003720.println("found " + rname + " = " + url); 63 64 java.net.URLConnection connection = url.openConnection(); 65 int contentLength = connection.getContentLength(); 66 byte[] buf = readFully(connection.getInputStream(), contentLength); 67 68 return Asmator.fixup(buf); 69 } catch (java.io.IOException ex) { 70 throw new Error(ex); 71 } 72 } 73 74 static byte[] readFully(java.io.InputStream in, int len) throws java.io.IOException { 75 byte[] b = in.readAllBytes(); 76 if (len != -1 && b.length != len) 77 throw new java.io.IOException("Expected:" + len + ", actual:" + b.length); 78 return b; 79 } 80 81 public void finalize() { 82 Test8003720.println("Goodbye from " + this); 83 } 84 85 public String toString() { 86 return "VictimClassLoader#" + which; 87 } 88 } |