Class.forName() patches
Archie Cobbs
archie at whistle.com
Tue Feb 29 11:19:49 PST 2000
Mo,
I've applied the following patches -- which are a modification of yours,
and now four tests are failing:
FAIL: Bean.java
FAIL: BeanBug.java
FAIL: Reflect.java
FAIL: ReflectInvoke.java
Could be my changes but they should be equivalent to yours..
I think the problem may be that kaffe calls classFromSig()
on types that are part of a larger string (and not necessarily
at the end of the string) such as function types.. eg:
"(Ljava/lang/String;II)V"
Please let me know what you want me to do...
-Archie
___________________________________________________________________________
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com
Index: classMethod.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/classMethod.c,v
retrieving revision 1.75
diff -u -r1.75 classMethod.c
--- classMethod.c 2000/01/19 11:04:31 1.75
+++ classMethod.c 2000/02/29 19:10:24
@@ -2287,6 +2287,12 @@
/* Build signature for array type */
if (CLASS_IS_PRIMITIVE (c)) {
+ /* An array of type void is not allowed */
+ if (strcmp(CLASS_CNAME(c), "void") == 0) {
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+ "invalid array of type void");
+ return (0);
+ }
arr_class = CLASS_ARRAY_CACHE(c);
if (arr_class) {
return (arr_class);
Index: itypes.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/itypes.c,v
retrieving revision 1.17
diff -u -r1.17 itypes.c
--- itypes.c 1999/11/29 23:44:10 1.17
+++ itypes.c 2000/02/29 19:10:24
@@ -136,24 +136,59 @@
const char* start;
const char* end;
+ /* Check for primitive types */
+ switch (**strp) {
+ case 'V':
+ cl = voidClass;
+ break;
+ case 'I':
+ cl = intClass;
+ break;
+ case 'Z':
+ cl = booleanClass;
+ break;
+ case 'S':
+ cl = shortClass;
+ break;
+ case 'B':
+ cl = byteClass;
+ break;
+ case 'C':
+ cl = charClass;
+ break;
+ case 'F':
+ cl = floatClass;
+ break;
+ case 'D':
+ cl = doubleClass;
+ break;
+ case 'J':
+ cl = longClass;
+ break;
+ default:
+ cl = 0;
+ break;
+ }
+ if (cl != 0) {
+ if (*++(*strp) != '\0') {
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+ "extra garbage after primitive type in signature");
+ return (NULL);
+ }
+ return cl;
+ }
+
+ /* Check for non-primitive and array types */
switch (*(*strp)++) {
- case 'V': return (voidClass);
- case 'I': return (intClass);
- case 'Z': return (booleanClass);
- case 'S': return (shortClass);
- case 'B': return (byteClass);
- case 'C': return (charClass);
- case 'F': return (floatClass);
- case 'D': return (doubleClass);
- case 'J': return (longClass);
- case '[': return (lookupArray(classFromSig(strp, loader, einfo),
- einfo));
+ case '[':
+ return lookupArray(classFromSig(strp, loader, einfo), einfo);
+
case 'L':
start = *strp;
- for (end = start; *end != 0 && *end != ';'; end++)
+ for (end = start; *end != '\0' && *end != ';'; end++)
;
*strp = end;
- if (*end != 0) {
+ if (*end != '\0') {
(*strp)++;
}
utf8 = utf8ConstNew(start, end - start);
@@ -163,10 +198,17 @@
}
cl = loadClass(utf8, loader, einfo);
utf8ConstRelease(utf8);
+ if (cl != 0 && CLASS_IS_PRIMITIVE(cl)) {
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+ "primitive type folllows `L' in signature");
+ cl = NULL;
+ }
return(cl);
+
default:
/* malformed signature */
- postException(einfo, JAVA_LANG(VerifyError));
+ postExceptionMessage(einfo, JAVA_LANG(VerifyError),
+ "malformed signature");
return (NULL);
}
}
More information about the kaffe
mailing list