2002-12-09 08:04:00 +08:00
|
|
|
/* Copyright (C) 1999, 2001, 2002 Free Software Foundation
|
1999-08-18 22:16:42 +08:00
|
|
|
|
|
|
|
This file is part of libgcj.
|
|
|
|
|
|
|
|
This software is copyrighted work licensed under the terms of the
|
|
|
|
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
/* Author: Kresten Krab Thorup <krab@gnu.org> */
|
|
|
|
|
|
|
|
package gnu.gcj.runtime;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.util.StringTokenizer;
|
|
|
|
import java.net.URL;
|
|
|
|
|
2001-05-22 03:27:10 +08:00
|
|
|
public final class VMClassLoader extends java.net.URLClassLoader
|
1999-08-18 22:16:42 +08:00
|
|
|
{
|
|
|
|
private VMClassLoader ()
|
|
|
|
{
|
|
|
|
super (init());
|
|
|
|
}
|
|
|
|
|
|
|
|
private static URL[] init()
|
|
|
|
{
|
|
|
|
StringTokenizer st
|
|
|
|
= new StringTokenizer (System.getProperty ("java.class.path", "."),
|
|
|
|
System.getProperty ("path.separator", ":"));
|
|
|
|
|
|
|
|
java.util.Vector p = new java.util.Vector();
|
|
|
|
while (st.hasMoreElements ())
|
|
|
|
{
|
|
|
|
String e = st.nextToken ();
|
|
|
|
try
|
|
|
|
{
|
2002-12-09 08:04:00 +08:00
|
|
|
if (!e.endsWith (File.separator) && new File (e).isDirectory ())
|
|
|
|
p.addElement (new URL("file", "", -1, e + File.separator));
|
1999-08-18 22:16:42 +08:00
|
|
|
else
|
2002-12-09 08:04:00 +08:00
|
|
|
p.addElement (new URL("file", "", -1, e));
|
1999-08-18 22:16:42 +08:00
|
|
|
}
|
|
|
|
catch (java.net.MalformedURLException x)
|
|
|
|
{
|
|
|
|
/* Ignore this path element */
|
|
|
|
}
|
|
|
|
}
|
2001-09-07 06:32:54 +08:00
|
|
|
// Add core:/ to the end of the java.class.path so any resources
|
|
|
|
// compiled into this executable may be found.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
p.addElement (new URL("core", "", -1, "/"));
|
|
|
|
}
|
|
|
|
catch (java.net.MalformedURLException x)
|
|
|
|
{
|
|
|
|
// This should never happen.
|
|
|
|
}
|
1999-08-18 22:16:42 +08:00
|
|
|
|
|
|
|
URL[] urls = new URL[p.size()];
|
|
|
|
p.copyInto (urls);
|
|
|
|
return urls;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** This is overridden to search the internal hash table, which
|
|
|
|
* will only search existing linked-in classes. This will make
|
|
|
|
* the default implementation of loadClass (in ClassLoader) work right.
|
2001-04-25 23:45:15 +08:00
|
|
|
* The implementation of this method is in java/lang/natClassLoader.cc.
|
1999-08-18 22:16:42 +08:00
|
|
|
*/
|
2001-04-25 23:45:15 +08:00
|
|
|
protected native Class findClass(String name)
|
|
|
|
throws java.lang.ClassNotFoundException;
|
1999-10-19 06:57:07 +08:00
|
|
|
|
|
|
|
// The only VMClassLoader that can exist.
|
2001-04-25 23:45:15 +08:00
|
|
|
public static VMClassLoader instance = new VMClassLoader ();
|
1999-08-18 22:16:42 +08:00
|
|
|
}
|