01: // Copyright (c) Corporation for National Research Initiatives
02:
03: package org.python.core;
04:
05: import java.util.Vector;
06:
07: /**
08: * A java1 classloader for loading compiled python modules.
09: *
10: * @deprecated java1 no longer supported.
11: */
12: class BytecodeLoader1 extends ClassLoader implements Loader {
13: private Vector parents;
14:
15: public BytecodeLoader1() {
16: this .parents = BytecodeLoader.init();
17: }
18:
19: public void addParent(ClassLoader referent) {
20: if (!this .parents.contains(referent)) {
21: this .parents.addElement(referent);
22: }
23: }
24:
25: // override from abstract base class
26: protected Class loadClass(String name, boolean resolve)
27: throws ClassNotFoundException {
28: Class c = findLoadedClass(name);
29: if (c != null) {
30: return c;
31: }
32: return BytecodeLoader.findParentClass(this .parents, name);
33: }
34:
35: public Class loadClassFromBytes(String name, byte[] data) {
36: Class c = defineClass(name, data, 0, data.length);
37: resolveClass(c);
38: BytecodeLoader.compileClass(c);
39: return c;
40: }
41: }
|