diff options
author | Tom Tromey <tromey@redhat.com> | 2005-04-05 22:26:26 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-04-05 22:26:26 +0000 |
commit | 8b6e76905300f33b868a3619d416cc9285cbfee1 (patch) | |
tree | 2e7ab5655ae0f92acaf1825446f2fec39bb2a56e /libjava/prims.cc | |
parent | 13148dd26aafe25ef31d5303f6383d464cc8db61 (diff) | |
download | gcc-8b6e76905300f33b868a3619d416cc9285cbfee1.tar.gz |
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
Diffstat (limited to 'libjava/prims.cc')
-rw-r--r-- | libjava/prims.cc | 79 |
1 files changed, 56 insertions, 23 deletions
diff --git a/libjava/prims.cc b/libjava/prims.cc index 70601712238..fadc466bc0e 100644 --- a/libjava/prims.cc +++ b/libjava/prims.cc @@ -675,46 +675,79 @@ _Jv_InitPrimClass (jclass cl, char *cname, char sig, int len) } jclass -_Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader) +_Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader, + char **endp) { + // First count arrays. + int array_count = 0; + while (*sig == '[') + { + ++sig; + ++array_count; + } + + jclass result = NULL; switch (*sig) { case 'B': - return JvPrimClass (byte); + result = JvPrimClass (byte); + break; case 'S': - return JvPrimClass (short); + result = JvPrimClass (short); + break; case 'I': - return JvPrimClass (int); + result = JvPrimClass (int); + break; case 'J': - return JvPrimClass (long); + result = JvPrimClass (long); + break; case 'Z': - return JvPrimClass (boolean); + result = JvPrimClass (boolean); + break; case 'C': - return JvPrimClass (char); + result = JvPrimClass (char); + break; case 'F': - return JvPrimClass (float); + result = JvPrimClass (float); + break; case 'D': - return JvPrimClass (double); + result = JvPrimClass (double); + break; case 'V': - return JvPrimClass (void); + result = JvPrimClass (void); + break; case 'L': { - int i; - for (i = 1; sig[i] && sig[i] != ';'; ++i) - ; - _Jv_Utf8Const *name = _Jv_makeUtf8Const (&sig[1], i - 1); - return _Jv_FindClass (name, loader); - } - case '[': - { - jclass klass = _Jv_FindClassFromSignature (&sig[1], loader); - if (! klass) - return NULL; - return _Jv_GetArrayClass (klass, loader); + char *save = ++sig; + while (*sig && *sig != ';') + ++sig; + // Do nothing if signature appears to be malformed. + if (*sig == ';') + { + _Jv_Utf8Const *name = _Jv_makeUtf8Const (save, sig - save); + result = _Jv_FindClass (name, loader); + } + break; } + default: + // Do nothing -- bad signature. + break; } - return NULL; // Placate compiler. + if (endp) + { + // Not really the "end", but the last valid character that we + // looked at. + *endp = sig; + } + + if (! result) + return NULL; + + // Find arrays. + while (array_count-- > 0) + result = _Jv_GetArrayClass (result, loader); + return result; } |