1:
8:
9: package ;
10:
11: import ;
12: import ;
13: import ;
14: import ;
15: import ;
16: import ;
17:
18: public final class SystemClassLoader extends URLClassLoader
19: {
20: SystemClassLoader(ClassLoader parent)
21: {
22: super(new URL[0], parent);
23: }
24:
25:
26:
27: private HashMap nativeClasses = new HashMap();
28:
29:
30:
31:
32: void addClass(Class klass)
33: {
34: String packageName = null;
35: String className = klass.getName();
36: int lastDot = className.lastIndexOf('.');
37: if (lastDot != -1)
38: packageName = className.substring(0, lastDot);
39: if (packageName != null && getPackage(packageName) == null)
40: {
41:
42:
43: definePackage(packageName, null, null, null, null, null, null, null);
44: }
45:
46:
47: nativeClasses.put(className, klass);
48: }
49:
50: protected native Class findClass(String name);
51:
52:
53:
54:
55:
56: void init()
57: {
58: String sep = File.pathSeparator;
59: StringTokenizer st
60: = new StringTokenizer (System.getProperty ("java.class.path", "."),
61: sep, true);
62:
63:
64: boolean last_was_sep = true;
65: while (st.hasMoreElements ())
66: {
67: String e = st.nextToken ();
68: try
69: {
70: if (sep.equals(e))
71: {
72: if (last_was_sep)
73: {
74:
75: addURL(new URL("file", "", -1, "./"));
76: last_was_sep = false;
77: }
78: else
79: last_was_sep = true;
80: continue;
81: }
82:
83: last_was_sep = false;
84: File path = new File(e);
85:
86: if (!path.exists())
87: continue;
88: if (!e.endsWith (File.separator) && path.isDirectory ())
89: addURL(new URL("file", "", -1, e + File.separator));
90: else
91: addURL(new URL("file", "", -1, e));
92: }
93: catch (java.net.MalformedURLException x)
94: {
95:
96: throw new RuntimeException(x);
97: }
98: }
99:
100: if (last_was_sep)
101: {
102: try
103: {
104: addURL(new URL("file", "", -1, "./"));
105: }
106: catch (java.net.MalformedURLException x)
107: {
108:
109: throw new RuntimeException(x);
110: }
111: }
112: }
113: }