01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2005 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package nice.tools.util;
12:
13: /**
14: A class loader that does not delegate to any parent, except
15: java* classes to the system classloader.
16:
17: @author Daniel Bonniot (bonniot@users.sf.net)
18: */
19:
20: public class SelfContainedClassLoader extends java.net.URLClassLoader {
21: public SelfContainedClassLoader(java.net.URL[] urls) {
22: super (urls);
23: }
24:
25: protected Class loadClass(String name, boolean resolve)
26: throws ClassNotFoundException {
27: Class res = this .findLoadedClass(name);
28:
29: if (res == null)
30: try {
31: res = this .findClass(name);
32: } catch (ClassNotFoundException e) {
33: }
34:
35: if (res == null && name.startsWith("java")) {
36: res = ClassLoader.getSystemClassLoader().loadClass(name);
37: }
38:
39: if (res == null)
40: throw new ClassNotFoundException(name);
41:
42: if (resolve)
43: this.resolveClass(res);
44:
45: return res;
46: }
47: }
|