blob: c0aa4d1cf0534adbfe34e5691ee3845f75e53419 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2000 Samuele Pedroni
package jxxload_help;
public class PathVFSJavaLoader extends ClassLoader {
private ClassLoader parent;
private PathVFS vfs;
public java.util.Vector interfaces = new java.util.Vector();
public PathVFSJavaLoader(PathVFS vfs,ClassLoader parent) {
this.vfs = vfs;
this.parent = parent;
}
protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
Class c;
c = findLoadedClass(name);
if (c != null) return c;
try {
if (parent != null) return parent.loadClass(name);
} catch(ClassNotFoundException e) {
}
java.io.InputStream in = vfs.open(name.replace('.','/')+".class");
if (in == null) throw new ClassNotFoundException(name);
try {
int av = in.available();
byte[] buf = new byte[av];
in.read(buf);
in.close();
return loadClassFromBytes(name,buf);
} catch(java.io.IOException e) {
throw new ClassNotFoundException(name);
}
}
private Class loadClassFromBytes(String name, byte[] data) {
Class c = defineClass(name, data, 0, data.length);
resolveClass(c);
if (c.isInterface()) interfaces.addElement(c);
if (!org.python.core.Options.skipCompile) {
Compiler.compileClass(c);
}
return c;
}
}
|