[gcjx] Patch: FYI: gcjx verifier and primitive types
Tom Tromey
tromey@redhat.com
Fri Sep 16 18:29:00 GMT 2005
I'm checking this in on the gcjx branch.
The gcjx verifier glue code wasn't handling primitive types properly.
This resulted in incorrect errors when generating bytecode with
verification enabled. Fixed as appended.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* verify.h (vfy_find_class): Handle primitive types.
Index: verify.h
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/Attic/verify.h,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 verify.h
--- verify.h 18 May 2005 00:09:10 -0000 1.1.2.7
+++ verify.h 16 Sep 2005 18:27:29 -0000
@@ -186,15 +186,60 @@
return NULL;
int nlen = len - offset;
- if (name[offset] == 'L' && name[len - 1] == ';')
+
+ vfy_jclass result = NULL;
+ if (nlen == 1)
{
- ++offset;
- nlen -= 2;
+ switch (name[offset])
+ {
+ case 'Z':
+ result = primitive_boolean_type;
+ break;
+ case 'B':
+ result = primitive_byte_type;
+ break;
+ case 'C':
+ result = primitive_char_type;
+ break;
+ case 'S':
+ result = primitive_short_type;
+ break;
+ case 'I':
+ result = primitive_int_type;
+ break;
+ case 'J':
+ result = primitive_long_type;
+ break;
+ case 'F':
+ result = primitive_float_type;
+ break;
+ case 'D':
+ result = primitive_double_type;
+ break;
+ case 'V':
+ result = primitive_void_type;
+ break;
+ default:
+ // This is goofy but we handle either kind of descriptor
+ // here and we might be looking for a class with a
+ // 1-character name.
+ break;
+ }
}
- std::string name_str (name, offset, nlen);
- vfy_jclass result = method->unit->find_class_from_descriptor (method->scope,
- method->method,
- name_str);
+
+ if (result == NULL)
+ {
+ if (name[offset] == 'L' && name[len - 1] == ';')
+ {
+ ++offset;
+ nlen -= 2;
+ }
+ std::string name_str (name, offset, nlen);
+ result = method->unit->find_class_from_descriptor (method->scope,
+ method->method,
+ name_str);
+ }
+
while (array_count-- > 0)
result = result->array ();
More information about the Java-patches
mailing list