1 /* Copyright (C) 2005, 2007 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 package gnu.gcj.runtime;
11 import gnu.java.net.protocol.core.Handler;
12 import java.io.IOException;
14 import java.util.Enumeration;
17 * This is a helper for the bootstrap class loader. It is a
18 * URLClassLoader so that we can read a class path and re-use all the
19 * existing code for finding classes, extracting them from jars, etc.
20 * However, it is never called the way that an ordinary ClassLoader is
21 * called. For instance, loadClass() is never used.
23 public final class BootClassLoader extends HelperClassLoader
25 // This forces the core URL handler to be included in statically
26 // linked executables. The line that adds core:/ to the search
27 // path fails otherwise.
28 static Class coreHandler = gnu.java.net.protocol.core.Handler.class;
30 BootClassLoader(String libdir)
32 // The BootClassLoader is the top of the delegation chain. It does not
34 super((ClassLoader) null);
35 addDirectoriesFromProperty("java.endorsed.dirs");
36 addDirectoriesFromProperty("gnu.gcj.runtime.endorsed.dirs");
40 // Add core:/ to the end so any resources compiled into this
41 // executable may be found.
42 addURL(new URL("core", "", -1, "/"));
44 catch (java.net.MalformedURLException x)
46 // This should never happen.
47 throw new RuntimeException(x);
51 public Class bootLoadClass(String name)
52 throws ClassNotFoundException
54 Class c = findLoadedClass(name);
59 // We could hack URLClassLoader to make this more
60 // efficient, if it mattered.
63 catch (ClassNotFoundException _)
71 public URL bootGetResource(String name)
73 return findResource(name);
76 public Enumeration bootGetResources(String name) throws IOException
78 return findResources(name);