This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: fix PR 27294
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 05 May 2006 09:02:00 -0600
- Subject: Patch: FYI: fix PR 27294
- Reply-to: tromey at redhat dot com
I'm checking this in on the trunk.
On platforms that don't enable the interpreter, we currently throw a
null pointer exception when trying to define a class from a .class
file.
This is unfriendly. This patch replaces this NPE with a
VirtualMachineError that has a useful message in it.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
PR libgcj/27294:
* java/lang/natVMClassLoader.cc (defineClass): Throw
VirtualMachineError if no interpreter configured.
Index: java/lang/natVMClassLoader.cc
===================================================================
--- java/lang/natVMClassLoader.cc (revision 113548)
+++ java/lang/natVMClassLoader.cc (working copy)
@@ -1,6 +1,6 @@
// natVMClassLoader.cc - VMClassLoader native methods
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
This file is part of libgcj.
@@ -34,6 +34,7 @@
#include <java/lang/StringBuffer.h>
#include <java/lang/Runtime.h>
#include <java/util/HashSet.h>
+#include <java/lang/VirtualMachineError.h>
java::lang::Class *
java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader,
@@ -94,6 +95,20 @@
}
#endif // INTERPRETER
+ if (! klass)
+ {
+ StringBuffer *sb = new StringBuffer();
+ if (name)
+ {
+ sb->append(JvNewStringLatin1("found class file for class "));
+ sb->append(name);
+ }
+ else
+ sb->append(JvNewStringLatin1("found unnamed class file"));
+ sb->append(JvNewStringLatin1(", but no interpreter configured in this libgcj"));
+ throw new VirtualMachineError(sb->toString());
+ }
+
return klass;
}