This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
resolveClass0 should throw LinkageErrors
- From: Mark Wielaard <mark at klomp dot org>
- To: java-patches at gcc dot gnu dot org
- Date: 12 Dec 2002 15:14:13 +0100
- Subject: resolveClass0 should throw LinkageErrors
- Organization:
Hi,
Since we are cleaning up classloading I came across resolveClass0 that
IMHO should only throw LinkageErrors. At least it should transform any
ClassNotFoundException to a NoClassDefFoundError.
2002-12-12 Mark Wielaard <mark@klomp.org>
* java/lang/ClassLoader.java (resolveClass0): Transform
ClassNotFoundException to NoClassDefFoundError. Transform all other
throwables to LinkageError.
OK to commit?
Cheers,
Mark
diff -u -r1.22 ClassLoader.java
--- java/lang/ClassLoader.java 11 Dec 2002 19:18:59 -0000 1.22
+++ java/lang/ClassLoader.java 12 Dec 2002 14:07:00 -0000
@@ -535,16 +535,22 @@
{
markClassErrorState0 (clazz);
- if (x instanceof Error)
- throw (Error)x;
+ LinkageError e;
+ if (x instanceof LinkageError)
+ e = (LinkageError)x;
+ else if (x instanceof ClassNotFoundException)
+ {
+ e = new NoClassDefFoundError("while resolving class: "
+ + clazz.getName());
+ e.initCause (x);
+ }
else
{
- InternalError e
- = new InternalError ("unexpected exception during linking: "
- + clazz.getName());
+ e = new LinkageError ("unexpected exception during linking: "
+ + clazz.getName());
e.initCause (x);
- throw e;
}
+ throw e;
}
}
}