re PR libgcj/26103 (Wrong exception thrown)

PR libgcj/26103:
	* java/lang/ClassLoader.java (loadClass): Don't throw
	StringIndexOutOfBoundsException if name is empty.
	* java/lang/natClassLoader.cc (loadClassFromSig): Throw exception
	if class not found.

From-SVN: r111820
This commit is contained in:
Tom Tromey 2006-03-07 21:39:44 +00:00 committed by Tom Tromey
parent 48fa302999
commit 9fe2e733d2
3 changed files with 14 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2006-03-07 Tom Tromey <tromey@redhat.com>
PR libgcj/26103:
* java/lang/ClassLoader.java (loadClass): Don't throw
StringIndexOutOfBoundsException if name is empty.
* java/lang/natClassLoader.cc (loadClassFromSig): Throw exception
if class not found.
2006-03-07 David Daney <ddaney@avtrex.com>
* include/java-interp.h: Removed extern "C" around #include <ffi.h>.

View File

@ -1,5 +1,5 @@
/* ClassLoader.java -- responsible for loading classes into the VM
Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -288,7 +288,7 @@ public abstract class ClassLoader
{
// Arrays are handled specially.
Class c;
if (name.charAt(0) == '[')
if (name.length() > 0 && name.charAt(0) == '[')
c = loadClassFromSig(name);
else
{

View File

@ -81,7 +81,10 @@ java::lang::ClassLoader::loadClassFromSig(jstring name)
int len = _Jv_GetStringUTFLength (name);
char sig[len + 1];
_Jv_GetStringUTFRegion (name, 0, name->length(), sig);
return _Jv_FindClassFromSignature(sig, this);
jclass result = _Jv_FindClassFromSignature(sig, this);
if (result == NULL)
throw new ClassNotFoundException(name);
return result;
}