SystemClassLoader.java (init): Handle empty element in path.

* gnu/gcj/runtime/SystemClassLoader.java (init): Handle empty
	element in path.

From-SVN: r99676
This commit is contained in:
Tom Tromey 2005-05-13 20:20:56 +00:00 committed by Tom Tromey
parent c2dba4ab40
commit 9c309ac9a4
2 changed files with 35 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2005-05-13 Tom Tromey <tromey@redhat.com>
* gnu/gcj/runtime/SystemClassLoader.java (init): Handle empty
element in path.
2005-05-12 Bryce McKinlay <mckinlay@redhat.com>
* include/jvm.h (gcj::verifyClasses): Declare.

View File

@ -27,16 +27,30 @@ public final class SystemClassLoader extends URLClassLoader
// causing a crash.
void init()
{
String sep = File.pathSeparator;
StringTokenizer st
= new StringTokenizer (System.getProperty ("java.class.path", "."),
File.pathSeparator);
sep, true);
// Pretend we start with a ':', so if we see a ':' first we add
// '.'.
boolean last_was_sep = true;
while (st.hasMoreElements ())
{
String e = st.nextToken ();
try
{
if ("".equals(e))
e = ".";
if (sep.equals(e))
{
if (last_was_sep)
{
// We saw two separators in a row, so add ".".
addURL(new URL("file", "", -1, "./"));
last_was_sep = false;
}
else
last_was_sep = true;
continue;
}
File path = new File(e);
// Ignore invalid paths.
@ -53,5 +67,18 @@ public final class SystemClassLoader extends URLClassLoader
throw new RuntimeException(x);
}
}
// If we saw a trailing ":", add "." to the path.
if (last_was_sep)
{
try
{
addURL(new URL("file", "", -1, "./"));
}
catch (java.net.MalformedURLException x)
{
// This should never happen.
throw new RuntimeException(x);
}
}
}
}