1 /* Copyright (C) 1999 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 /* Author: Kresten Krab Thorup <krab@gnu.org> */
11 package gnu.gcj.runtime;
14 import java.util.StringTokenizer;
17 final class VMClassLoader extends java.net.URLClassLoader
19 private VMClassLoader ()
24 private static URL[] init()
27 = new StringTokenizer (System.getProperty ("java.class.path", "."),
28 System.getProperty ("path.separator", ":"));
30 java.util.Vector p = new java.util.Vector();
31 while (st.hasMoreElements ())
33 String e = st.nextToken ();
36 if (e.endsWith(".jar") || e.endsWith (".zip"))
37 p.addElement(new URL("jar", "", -1, "file:///"+e+"!/"));
38 else if (e.endsWith ("/"))
39 p.addElement (new URL("file", "", -1, e));
40 else if (new File (e).isDirectory ())
41 p.addElement (new URL("file", "", -1, e + "/"));
43 /* Ignore path element. */;
45 catch (java.net.MalformedURLException x)
47 /* Ignore this path element */
51 URL[] urls = new URL[p.size()];
56 /** This is overridden to search the internal hash table, which
57 * will only search existing linked-in classes. This will make
58 * the default implementation of loadClass (in ClassLoader) work right.
60 protected final native Class findSystemClass(String name)
61 throws java.lang.ClassNotFoundException, java.lang.LinkageError;
63 // Return the sole VMClassLoader.
64 private static synchronized VMClassLoader getVMClassLoader ()
67 redirect = new VMClassLoader ();
71 // The only VMClassLoader that can exist.
72 private static VMClassLoader redirect;