1:
8:
9: package ;
10:
11: import ;
12: import ;
13: import ;
14: import ;
15: import ;
16: import ;
17: import ;
18: import ;
19:
20:
27: public final class BootClassLoader extends HelperClassLoader
28: {
29:
30:
31:
32: static Class coreHandler = gnu.java.net.protocol.core.Handler.class;
33:
34: private boolean initialized;
35: private URLClassLoader bootURLLoader;
36:
37: BootClassLoader(String libdir)
38: {
39:
40:
41: super((ClassLoader) null);
42: addDirectoriesFromProperty("java.endorsed.dirs");
43: addDirectoriesFromProperty("gnu.gcj.runtime.endorsed.dirs");
44:
45: try
46: {
47:
48:
49: addURL(new URL("core", "", -1, "/"));
50: }
51: catch (java.net.MalformedURLException x)
52: {
53:
54: throw new RuntimeException(x);
55: }
56: }
57:
58: public Class bootLoadClass(String name)
59: throws ClassNotFoundException
60: {
61: Class c = findLoadedClass(name);
62: if (c == null)
63: {
64: try
65: {
66:
67:
68: c = findClass(name);
69: }
70: catch (ClassNotFoundException _)
71: {
72: c = null;
73: }
74: }
75: return c;
76: }
77:
78:
79:
80:
81:
82: private synchronized URLClassLoader getBootURLLoader()
83: {
84: if (initialized)
85: return bootURLLoader;
86: initialized = true;
87:
88: Vector<URL> urls = new Vector<URL>();
89: String bootClasspath = System.getProperty ("sun.boot.class.path");
90: StringTokenizer st =
91: new StringTokenizer(bootClasspath, File.pathSeparator);
92: while (st.hasMoreTokens())
93: {
94: try
95: {
96: urls.add(new File(st.nextToken()).toURL());
97: }
98: catch (java.net.MalformedURLException e)
99: {
100: }
101: }
102:
103: if (urls.size() > 0)
104: bootURLLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
105: return bootURLLoader;
106: }
107:
108: public URL bootGetResource(String name)
109: {
110: URL url = findResource(name);
111: if (url != null)
112: return url;
113:
114: URLClassLoader loader = getBootURLLoader();
115: if (loader != null)
116: url = loader.findResource(name);
117:
118: return url;
119: }
120:
121: public Enumeration bootGetResources(String name) throws IOException
122: {
123: URLClassLoader loader = getBootURLLoader();
124: Enumeration[] e =
125: {
126: findResources(name),
127: (loader != null) ? loader.findResources(name) : null
128: };
129:
130: Vector v = new Vector();
131: for (Enumeration en : e)
132: if (en != null)
133: while (en.hasMoreElements())
134: v.add(en.nextElement());
135:
136: return v.elements();
137: }
138: }