44 |
import java.util.Enumeration; |
import java.util.Enumeration; |
45 |
import java.util.Map; |
import java.util.Map; |
46 |
import java.util.HashMap; |
import java.util.HashMap; |
47 |
|
import java.lang.reflect.Constructor; |
48 |
|
import gnu.java.lang.SystemClassLoader; |
49 |
|
|
50 |
import gnu.java.util.EmptyEnumeration; |
import gnu.java.util.EmptyEnumeration; |
51 |
|
|
297 |
{ |
{ |
298 |
return new HashMap(); |
return new HashMap(); |
299 |
} |
} |
300 |
|
|
301 |
|
static ClassLoader getSystemClassLoader() |
302 |
|
{ |
303 |
|
// This method is called as the initialization of systemClassLoader, |
304 |
|
// so if there is a null value, this is the first call and we must check |
305 |
|
// for java.system.class.loader. |
306 |
|
String loader = System.getProperty("java.system.class.loader", |
307 |
|
"gnu.java.lang.SystemClassLoader"); |
308 |
|
try |
309 |
|
{ |
310 |
|
// Give the new system class loader a null parent. |
311 |
|
Constructor c = Class.forName(loader).getConstructor |
312 |
|
( new Class[] { ClassLoader.class } ); |
313 |
|
return (ClassLoader) c.newInstance(new Object[1]); |
314 |
|
} |
315 |
|
catch (Exception e) |
316 |
|
{ |
317 |
|
try |
318 |
|
{ |
319 |
|
System.err.println("Requested system classloader " |
320 |
|
+ loader + " failed, trying " |
321 |
|
+ "gnu.java.lang.SystemClassLoader"); |
322 |
|
e.printStackTrace(); |
323 |
|
// Fallback to gnu.java.lang.SystemClassLoader. |
324 |
|
return new SystemClassLoader(null); |
325 |
|
} |
326 |
|
catch (Exception e1) |
327 |
|
{ |
328 |
|
throw (Error) new InternalError |
329 |
|
("System class loader could not be found: " + e1) |
330 |
|
.initCause(e1); |
331 |
|
} |
332 |
|
} |
333 |
|
|
334 |
|
} |
335 |
} |
} |