From d386f78b40ccdb8ed6413565614aa43cdf7fb40b Mon Sep 17 00:00:00 2001 From: tromey Date: Fri, 13 May 2005 20:20:56 +0000 Subject: [PATCH] * gnu/gcj/runtime/SystemClassLoader.java (init): Handle empty element in path. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99676 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 5 ++++ libjava/gnu/gcj/runtime/SystemClassLoader.java | 33 +++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 469bb76..93060fa 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2005-05-13 Tom Tromey + + * gnu/gcj/runtime/SystemClassLoader.java (init): Handle empty + element in path. + 2005-05-12 Bryce McKinlay * include/jvm.h (gcj::verifyClasses): Declare. diff --git a/libjava/gnu/gcj/runtime/SystemClassLoader.java b/libjava/gnu/gcj/runtime/SystemClassLoader.java index 163d3dd..e68770c 100644 --- a/libjava/gnu/gcj/runtime/SystemClassLoader.java +++ b/libjava/gnu/gcj/runtime/SystemClassLoader.java @@ -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); + } + } } } -- 2.7.4