OSDN Git Service

* java/lang/natThread.cc (finish_): Don't clear 'group'.
[pf3gnuchains/gcc-fork.git] / libjava / gnu / gcj / runtime / BootClassLoader.java
1 /* Copyright (C) 2005  Free Software Foundation
2
3    This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7 details.  */
8
9 package gnu.gcj.runtime;
10
11 import java.io.IOException;
12 import java.net.URL;
13 import java.util.Enumeration;
14
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.
21  */
22 public final class BootClassLoader extends HelperClassLoader
23 {
24   BootClassLoader(String libdir)
25   {
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");
31
32     try
33       {
34         // Add core:/ to the end so any resources compiled into this
35         // executable may be found.
36         addURL(new URL("core", "", -1, "/"));
37       }
38     catch (java.net.MalformedURLException x)
39       {
40         // This should never happen.
41         throw new RuntimeException(x);
42       }
43   }
44
45   public Class bootLoadClass(String name)
46     throws ClassNotFoundException
47   {
48     Class c = findLoadedClass(name);
49     if (c == null)
50       {
51         try
52           {
53             // We could hack URLClassLoader to make this more
54             // efficient, if it mattered.
55             c = findClass(name);
56           }
57         catch (ClassNotFoundException _)
58           {
59             c = null;
60           }
61       }
62     return c;
63   }
64
65   public URL bootGetResource(String name)
66   {
67     return findResource(name);
68   }
69
70   public Enumeration bootGetResources(String name) throws IOException
71   {
72     return findResources(name);
73   }
74 }