Patch: JNI fix for NewObject
Tom Tromey
tromey@cygnus.com
Wed Feb 16 14:41:00 GMT 2000
I'm committing this patch. It fixes a few bad assertions, and it
fixes an actual bug in the JNI NewObject function.
2000-02-16 Tom Tromey <tromey@cygnus.com>
* jni.cc (_Jv_JNI_NewObjectV): Corrected assertion.
(_Jv_JNI_NewObject): Likewise.
(_Jv_JNI_NewObjectA): Likewise.
(_Jv_JNI_CallAnyMethodV): In constructor case, pass correct value
as "return" type to _Jv_CallAnyMethodA.
(_Jv_JNI_CallAnyMethodA): Likewise.
(_Jv_JNI_CallAnyVoidMethodV): Likewise.
Tom
Index: jni.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/jni.cc,v
retrieving revision 1.18
diff -u -r1.18 jni.cc
--- jni.cc 2000/02/16 18:42:48 1.18
+++ jni.cc 2000/02/16 22:36:39
@@ -560,6 +560,10 @@
jvalue args[arg_types->length];
array_from_valist (args, arg_types, vargs);
+ // For constructors we need to pass the Class we are instantiating.
+ if (style == constructor)
+ return_type = klass;
+
jvalue result;
jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor,
@@ -604,6 +608,10 @@
_Jv_GetTypesFromSignature (id, decl_class,
&arg_types, &return_type);
+ // For constructors we need to pass the Class we are instantiating.
+ if (style == constructor)
+ return_type = klass;
+
jvalue result;
jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor,
@@ -636,6 +644,10 @@
jvalue args[arg_types->length];
array_from_valist (args, arg_types, vargs);
+ // For constructors we need to pass the Class we are instantiating.
+ if (style == constructor)
+ return_type = klass;
+
jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor,
arg_types, args, NULL);
@@ -804,7 +816,11 @@
{
JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>")
- && ! strcmp (id->signature->data, "()V"));
+ && id->signature->length > 2
+ && id->signature->data[0] == '('
+ && ! strcmp (&id->signature->data[id->signature->length - 2],
+ ")V"));
+
return _Jv_JNI_CallAnyMethodV<jobject, constructor> (env, NULL, klass,
id, args);
}
@@ -814,7 +830,10 @@
{
JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>")
- && ! strcmp (id->signature->data, "()V"));
+ && id->signature->length > 2
+ && id->signature->data[0] == '('
+ && ! strcmp (&id->signature->data[id->signature->length - 2],
+ ")V"));
va_list args;
jobject result;
@@ -833,7 +852,11 @@
{
JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>")
- && ! strcmp (id->signature->data, "()V"));
+ && id->signature->length > 2
+ && id->signature->data[0] == '('
+ && ! strcmp (&id->signature->data[id->signature->length - 2],
+ ")V"));
+
return _Jv_JNI_CallAnyMethodA<jobject, constructor> (env, NULL, klass,
id, args);
}
More information about the Java-patches
mailing list