MCPcopy Create free account
hub / github.com/ReadyTalk/avian / findClass

Method findClass

classpath/java/net/URLClassLoader.java:35–56  ·  view source on GitHub ↗
(String name)

Source from the content-addressed store, hash-verified

33
34
35 protected Class findClass(String name) throws ClassNotFoundException {
36 try {
37 InputStream stream = getResourceAsStream(name.replace(".", "/") + ".class");
38 if(stream == null) {
39 throw new ClassNotFoundException("couldn't find class " + name);
40 }
41 byte[] buf = new byte[2048];
42 ByteArrayOutputStream mem = new ByteArrayOutputStream();
43 try {
44 int size;
45 while((size = stream.read(buf, 0, buf.length)) > 0) {
46 mem.write(buf, 0, size);
47 }
48 byte[] data = mem.toByteArray();
49 return defineClass(name, data, 0, data.length);
50 } finally {
51 stream.close();
52 }
53 } catch(IOException e) {
54 throw new ClassNotFoundException("couldn't find class " + name, e);
55 }
56 }
57
58 public URL getResource(String path) {
59 try {

Callers

nothing calls this directly

Calls 7

readMethod · 0.95
writeMethod · 0.95
toByteArrayMethod · 0.95
closeMethod · 0.95
replaceMethod · 0.65
getResourceAsStreamMethod · 0.45
defineClassMethod · 0.45

Tested by

no test coverage detected