SystemClassLoader.java [plain text]
package gnu.gcj.runtime;
import java.io.*;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.net.URL;
import java.net.URLClassLoader;
public final class SystemClassLoader extends URLClassLoader
{
SystemClassLoader(ClassLoader parent)
{
super(new URL[0], parent);
}
void init()
{
String sep = File.pathSeparator;
StringTokenizer st
= new StringTokenizer (System.getProperty ("java.class.path", "."),
sep, true);
boolean last_was_sep = true;
while (st.hasMoreElements ())
{
String e = st.nextToken ();
try
{
if (sep.equals(e))
{
if (last_was_sep)
{
addURL(new URL("file", "", -1, "./"));
last_was_sep = false;
}
else
last_was_sep = true;
continue;
}
File path = new File(e);
if (!path.exists())
continue;
if (!e.endsWith (File.separator) && path.isDirectory ())
addURL(new URL("file", "", -1, e + File.separator));
else
addURL(new URL("file", "", -1, e));
}
catch (java.net.MalformedURLException x)
{
throw new RuntimeException(x);
}
}
if (last_was_sep)
{
try
{
addURL(new URL("file", "", -1, "./"));
}
catch (java.net.MalformedURLException x)
{
throw new RuntimeException(x);
}
}
}
}