136 |
/** |
/** |
137 |
* Helper to load a resource from the bootstrap class loader. |
* Helper to load a resource from the bootstrap class loader. |
138 |
* |
* |
|
* XXX - Not implemented; this requires native help. |
|
|
* |
|
139 |
* @param name the resource to find |
* @param name the resource to find |
140 |
* @return the URL to the resource |
* @return the URL to the resource |
141 |
*/ |
*/ |
142 |
static URL getResource(String name) |
static URL getResource(String name) |
143 |
{ |
{ |
144 |
|
Enumeration e = getResources(name); |
145 |
|
if (e.hasMoreElements()) |
146 |
|
return (URL)e.nextElement(); |
147 |
return null; |
return null; |
148 |
} |
} |
149 |
|
|
150 |
/** |
/** |
151 |
* Helper to get a list of resources from the bootstrap class loader. |
* Helper to get a list of resources from the bootstrap class loader. |
152 |
* |
* |
|
* XXX - Not implemented; this requires native help. |
|
|
* |
|
153 |
* @param name the resource to find |
* @param name the resource to find |
154 |
* @return an enumeration of resources |
* @return an enumeration of resources |
155 |
* @throws IOException if one occurs |
* @throws IOException if one occurs |
156 |
*/ |
*/ |
157 |
static Enumeration getResources(String name) throws IOException |
static Enumeration getResources(String name) |
158 |
{ |
{ |
159 |
return EmptyEnumeration.getInstance(); |
StringTokenizer st = new StringTokenizer( |
160 |
|
ClassLoader.getSystemProperty("java.boot.class.path", "."), |
161 |
|
File.pathSeparator); |
162 |
|
Vector v = new Vector(); |
163 |
|
while (st.hasMoreTokens()) |
164 |
|
{ |
165 |
|
File file = new File(st.nextToken(), name); |
166 |
|
if (!file.exists()) |
167 |
|
continue; |
168 |
|
try |
169 |
|
{ |
170 |
|
v.add(new URL("file://" + file.getAbsolutePath())); |
171 |
|
} |
172 |
|
catch (MalformedURLException e) |
173 |
|
{ |
174 |
|
throw new Error(e); |
175 |
|
} |
176 |
|
} |
177 |
|
return v.elements(); |
178 |
} |
} |
179 |
|
|
180 |
/** |
/** |
325 |
|
|
326 |
static ClassLoader getSystemClassLoader() |
static ClassLoader getSystemClassLoader() |
327 |
{ |
{ |
328 |
// This method is called as the initialization of systemClassLoader, |
return ClassLoader.defaultGetSystemClassLoader(); |
|
// so if there is a null value, this is the first call and we must check |
|
|
// for java.system.class.loader. |
|
|
String loader = System.getProperty("java.system.class.loader", |
|
|
"gnu.java.lang.SystemClassLoader"); |
|
|
try |
|
|
{ |
|
|
// Give the new system class loader a null parent. |
|
|
Constructor c = Class.forName(loader).getConstructor |
|
|
( new Class[] { ClassLoader.class } ); |
|
|
return (ClassLoader) c.newInstance(new Object[1]); |
|
|
} |
|
|
catch (Exception e) |
|
|
{ |
|
|
try |
|
|
{ |
|
|
System.err.println("Requested system classloader " |
|
|
+ loader + " failed, trying " |
|
|
+ "gnu.java.lang.SystemClassLoader"); |
|
|
e.printStackTrace(); |
|
|
// Fallback to gnu.java.lang.SystemClassLoader. |
|
|
return new SystemClassLoader(null); |
|
|
} |
|
|
catch (Exception e1) |
|
|
{ |
|
|
throw (Error) new InternalError |
|
|
("System class loader could not be found: " + e1) |
|
|
.initCause(e1); |
|
|
} |
|
|
} |
|
|
|
|
329 |
} |
} |
330 |
} |
} |