Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / gnu / gcj / runtime / BootClassLoader.java
blob84952359aabb78b603ce5f87fc57c0c190ced96b
1 /* Copyright (C) 2005 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
7 details. */
9 package gnu.gcj.runtime;
11 import java.io.IOException;
12 import java.net.URL;
13 import java.util.Enumeration;
15 /**
16 * This is a helper for the bootstrap class loader. It is a
17 * URLClassLoader so that we can read a class path and re-use all the
18 * existing code for finding classes, extracting them from jars, etc.
19 * However, it is never called the way that an ordinary ClassLoader is
20 * called. For instance, loadClass() is never used.
22 public final class BootClassLoader extends HelperClassLoader
24 BootClassLoader(String libdir)
26 // The BootClassLoader is the top of the delegation chain. It does not
27 // have a parent.
28 super((ClassLoader) null);
29 addDirectoriesFromProperty("java.endorsed.dirs");
30 addDirectoriesFromProperty("gnu.gcj.runtime.endorsed.dirs");
32 try
34 // Add core:/ to the end so any resources compiled into this
35 // executable may be found.
36 addURL(new URL("core", "", -1, "/"));
38 catch (java.net.MalformedURLException x)
40 // This should never happen.
41 throw new RuntimeException(x);
45 public Class bootLoadClass(String name)
46 throws ClassNotFoundException
48 Class c = findLoadedClass(name);
49 if (c == null)
51 try
53 // We could hack URLClassLoader to make this more
54 // efficient, if it mattered.
55 c = findClass(name);
57 catch (ClassNotFoundException _)
59 c = null;
62 return c;
65 public URL bootGetResource(String name)
67 return findResource(name);
70 public Enumeration bootGetResources(String name) throws IOException
72 return findResources(name);