jni.cc (_Jv_JNI_GetAnyFieldID): Throw ClassNotFoundException.
* jni.cc (_Jv_JNI_GetAnyFieldID): Throw ClassNotFoundException. * java/lang/reflect/natMethod.cc (_Jv_GetTypesFromSignature): Rewrote to use _Jv_FindClassFromSignature. * verify.cc (resolve): throw NoClassDefFoundError. * link.cc (resolve_field): Throw NoClassDefFoundError. (find_field): Likewise. * prims.cc (_Jv_FindClassFromSignature): Removed recursion. Handle error cases. Added 'endp' argument. * include/jvm.h (_Jv_FindClassFromSignature): Updated prototype. From-SVN: r97660
This commit is contained in:
@@ -252,27 +252,30 @@ _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
|
||||
// Not even a bootstrap loader, try the built-in cache.
|
||||
klass = _Jv_FindClassInCache (name);
|
||||
|
||||
bool found = false;
|
||||
for (int i = 0; i < bootstrap_index; ++i)
|
||||
if (klass)
|
||||
{
|
||||
if (bootstrap_class_list[i] == klass)
|
||||
bool found = false;
|
||||
for (int i = 0; i < bootstrap_index; ++i)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
if (bootstrap_class_list[i] == klass)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! found)
|
||||
{
|
||||
if (bootstrap_index == BOOTSTRAP_CLASS_LIST_SIZE)
|
||||
abort ();
|
||||
bootstrap_class_list[bootstrap_index++] = klass;
|
||||
}
|
||||
}
|
||||
if (! found)
|
||||
{
|
||||
if (bootstrap_index == BOOTSTRAP_CLASS_LIST_SIZE)
|
||||
abort ();
|
||||
bootstrap_class_list[bootstrap_index++] = klass;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we need classes to be in the hash while
|
||||
// we're loading, so that they can refer to themselves.
|
||||
// We need classes to be in the hash while we're loading, so
|
||||
// that they can refer to themselves.
|
||||
_Jv_Linker::wait_for_state (klass, JV_STATE_LOADED);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,7 @@ java::lang::VMClassLoader::getPrimitiveClass (jchar type)
|
||||
char sig[2];
|
||||
sig[0] = (char) type;
|
||||
sig[1] = '\0';
|
||||
// Note: this cannot return NULL, since the input is always correct.
|
||||
return _Jv_FindClassFromSignature (sig, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ details. */
|
||||
#include <java/lang/Class.h>
|
||||
#include <gcj/method.h>
|
||||
#include <gnu/gcj/RawData.h>
|
||||
#include <java/lang/NoClassDefFoundError.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -235,6 +236,8 @@ _Jv_GetTypesFromSignature (jmethodID method,
|
||||
char *ptr = sig->chars();
|
||||
int numArgs = 0;
|
||||
/* First just count the number of parameters. */
|
||||
// FIXME: should do some validation here, e.g., that there is only
|
||||
// one return type.
|
||||
for (; ; ptr++)
|
||||
{
|
||||
switch (*ptr)
|
||||
@@ -271,44 +274,26 @@ _Jv_GetTypesFromSignature (jmethodID method,
|
||||
jclass* argPtr = elements (args);
|
||||
for (ptr = sig->chars(); *ptr != '\0'; ptr++)
|
||||
{
|
||||
int num_arrays = 0;
|
||||
jclass type;
|
||||
for (; *ptr == '['; ptr++)
|
||||
num_arrays++;
|
||||
switch (*ptr)
|
||||
if (*ptr == '(')
|
||||
continue;
|
||||
if (*ptr == ')')
|
||||
{
|
||||
default:
|
||||
return;
|
||||
case ')':
|
||||
argPtr = return_type_out;
|
||||
continue;
|
||||
case '(':
|
||||
continue;
|
||||
case 'V':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'F':
|
||||
case 'S':
|
||||
case 'I':
|
||||
case 'J':
|
||||
case 'Z':
|
||||
type = _Jv_FindClassFromSignature(ptr, loader);
|
||||
break;
|
||||
case 'L':
|
||||
type = _Jv_FindClassFromSignature(ptr, loader);
|
||||
do
|
||||
ptr++;
|
||||
while (*ptr != ';' && ptr[1] != '\0');
|
||||
break;
|
||||
}
|
||||
|
||||
while (--num_arrays >= 0)
|
||||
type = _Jv_GetArrayClass (type, loader);
|
||||
char *end_ptr;
|
||||
jclass type = _Jv_FindClassFromSignature (ptr, loader, &end_ptr);
|
||||
if (type == NULL)
|
||||
// FIXME: This isn't ideal.
|
||||
throw new java::lang::NoClassDefFoundError (sig->toString());
|
||||
|
||||
// ARGPTR can be NULL if we are processing the return value of a
|
||||
// call from Constructor.
|
||||
if (argPtr)
|
||||
*argPtr++ = type;
|
||||
|
||||
ptr = end_ptr;
|
||||
}
|
||||
*arg_types_out = args;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user