diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-12 13:51:11 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-12 13:51:11 +0000 |
commit | dccb958c636e1a082b8b910c422a851df75b83ba (patch) | |
tree | d1a4c371ccfdcb609926e0a4c67a184227910bb5 /libjava/java | |
parent | 6b7c3f60205a9024b68a91c953d36a4d93d953ec (diff) | |
download | ppe42-gcc-dccb958c636e1a082b8b910c422a851df75b83ba.tar.gz ppe42-gcc-dccb958c636e1a082b8b910c422a851df75b83ba.zip |
Fixes bug libgcj/8170
* java/lang/ClassLoader.java (loadClass): Don't rewrap
ClassNotFoundException.
* gnu/java/lang/MainThread.java (run): Chain NoClassDefFoundError.
* gnu/gcj/runtime/NameFinder.java (remove_interpreter): Removed.
(remove_internal): New field superceding remove_interpreter.
(sanitizeStack): Remove all no-package classes starting with "_Jv_".
Remove no-class methods starting with "_Jv_". And Replace null
class or method names with the empty string. Stop at either the
MainThread or a real Thread run() method.
(newElement): Made static.
* java/net/URLClassLoader.java (findClass): Throw
ClassNotFoundExceptions including urls, plus parent using toString().
(thisString): New field.
(toString): New method.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94935 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/ClassLoader.java | 15 | ||||
-rw-r--r-- | libjava/java/net/URLClassLoader.java | 41 |
2 files changed, 39 insertions, 17 deletions
diff --git a/libjava/java/lang/ClassLoader.java b/libjava/java/lang/ClassLoader.java index 71f41c1cf1b..46e523c6834 100644 --- a/libjava/java/lang/ClassLoader.java +++ b/libjava/java/lang/ClassLoader.java @@ -288,8 +288,6 @@ public abstract class ClassLoader if (c != null) return c; - ClassNotFoundException ex = null; - // Can the class be loaded by a parent? try { @@ -306,20 +304,9 @@ public abstract class ClassLoader } catch (ClassNotFoundException e) { - ex = e; } // Still not found, we have to do it ourself. - try - { - c = findClass(name); - } - catch (ClassNotFoundException cause) - { - if (ex != null) - throw new ClassNotFoundException(ex.toString(), cause); - else - throw cause; - } + c = findClass(name); if (resolve) resolveClass(c); return c; diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java index 3efc5dca76f..0da6a0356b2 100644 --- a/libjava/java/net/URLClassLoader.java +++ b/libjava/java/net/URLClassLoader.java @@ -1,5 +1,6 @@ /* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -958,7 +959,7 @@ public class URLClassLoader extends SecureClassLoader resource = loader.getResource(resourceName); } if (resource == null) - throw new ClassNotFoundException(className + " not found in " + urls); + throw new ClassNotFoundException(className + " not found in " + this); // Try to read the class data, create the CodeSource, Package and // construct the class (and watch out for those nasty IOExceptions) @@ -1039,9 +1040,43 @@ public class URLClassLoader extends SecureClassLoader } catch (IOException ioe) { - throw new ClassNotFoundException(className, ioe); + ClassNotFoundException cnfe; + cnfe = new ClassNotFoundException(className + " not found in " + this); + cnfe.initCause(ioe); + throw cnfe; } } + + // Cached String representation of this URLClassLoader + private String thisString; + + /** + * Returns a String representation of this URLClassLoader giving the + * actual Class name, the URLs that are searched and the parent + * ClassLoader. + */ + public String toString() + { + if (thisString == null) + { + StringBuffer sb = new StringBuffer(); + sb.append(this.getClass().getName()); + sb.append("{urls=[" ); + URL[] thisURLs = getURLs(); + for (int i = 0; i < thisURLs.length; i++) + { + sb.append(thisURLs[i]); + if (i < thisURLs.length - 1) + sb.append(','); + } + sb.append(']'); + sb.append(", parent="); + sb.append(getParent()); + sb.append('}'); + thisString = sb.toString(); + } + return thisString; + } /** * Finds the first occurrence of a resource that can be found. The locations |