Patch: FYI: NoClassDefFound
Tom Tromey
tromey@redhat.com
Wed Sep 25 14:01:00 GMT 2002
I'm checking this in.
There are a few places where we throw ClassNotFoundException, where
instead I think we should throw NoClassDefFound. This patch fixes
this problem.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/lang/natClassLoader.cc:
(_Jv_PrepareCompiledClass): Throw NoClassDefFoundError, per spec.
* resolve.cc: Include NoClassDefFoundError.h, not
ClassNotFoundException.h.
(_Jv_ResolvePoolEntry): Throw NoClassDefFoundError, per spec.
* defineclass.cc: Don't include ClassNotFoundException.h.
Index: defineclass.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/defineclass.cc,v
retrieving revision 1.29
diff -u -r1.29 defineclass.cc
--- defineclass.cc 24 Jun 2002 20:38:45 -0000 1.29
+++ defineclass.cc 25 Sep 2002 20:48:19 -0000
@@ -35,7 +35,6 @@
#include <java/lang/ClassFormatError.h>
#include <java/lang/NoClassDefFoundError.h>
#include <java/lang/ClassCircularityError.h>
-#include <java/lang/ClassNotFoundException.h>
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/reflect/Modifier.h>
Index: resolve.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/resolve.cc,v
retrieving revision 1.30
diff -u -r1.30 resolve.cc
--- resolve.cc 25 Sep 2002 20:40:09 -0000 1.30
+++ resolve.cc 25 Sep 2002 20:48:20 -0000
@@ -29,7 +29,7 @@
#include <java/lang/ClassFormatError.h>
#include <java/lang/IllegalAccessError.h>
#include <java/lang/AbstractMethodError.h>
-#include <java/lang/ClassNotFoundException.h>
+#include <java/lang/NoClassDefFoundError.h>
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/reflect/Modifier.h>
@@ -98,7 +98,8 @@
if (! found)
{
jstring str = _Jv_NewStringUTF (name->data);
- throw new java::lang::ClassNotFoundException (str);
+ // This exception is specified in JLS 2nd Ed, section 5.1.
+ throw new java::lang::NoClassDefFoundError (str);
}
if ((found->accflags & Modifier::PUBLIC) == Modifier::PUBLIC
Index: java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.49
diff -u -r1.49 natClassLoader.cc
--- java/lang/natClassLoader.cc 25 Jun 2002 05:29:20 -0000 1.49
+++ java/lang/natClassLoader.cc 25 Sep 2002 20:48:22 -0000
@@ -260,7 +260,7 @@
if (! found)
{
jstring str = _Jv_NewStringUTF (name->data);
- throw new java::lang::ClassNotFoundException (str);
+ throw new java::lang::NoClassDefFoundError (str);
}
pool->data[index].clazz = found;
More information about the Java-patches
mailing list