01: /*
02: * @(#)ByteCodeLoader.java 1.2 04/12/06
03: *
04: * Copyright (c) 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.beans;
10:
11: class ByteCodeLoader extends ClassLoader {
12:
13: ClassLoader parent;
14:
15: ByteCodeLoader() {
16: }
17:
18: ByteCodeLoader(ClassLoader parent) {
19: this .parent = parent;
20: }
21:
22: protected Class loadClass(String name, boolean resolve)
23: throws ClassNotFoundException {
24: Class c = findLoadedClass(name);
25: if (c == null) {
26: try {
27: c = findSystemClass(name);
28: } catch (ClassNotFoundException e) {
29: if (parent != null) {
30: c = parent.loadClass(name);
31: } else {
32: throw e;
33: }
34: }
35: }
36: if (resolve) {
37: resolveClass(c);
38: }
39: return c;
40: }
41:
42: Class define(String cname, byte[] bytecode, int offset, int size) {
43: Class c = defineClass(cname, bytecode, offset, size);
44: resolveClass(c);
45: return c;
46: }
47: }
|