Commit 1adbc4d8 by Tom Tromey Committed by Tom Tromey

jni.cc (_Jv_JNI_NewObjectV): Corrected assertion.

	* 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.

From-SVN: r32017
parent 5b0d59b4
2000-02-16 Tom Tromey <tromey@cygnus.com> 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.
* jni.cc (_Jv_JNI_FindClass): Use ClassLoader.loadClass, not * jni.cc (_Jv_JNI_FindClass): Use ClassLoader.loadClass, not
findClass. findClass.
......
...@@ -560,6 +560,10 @@ _Jv_JNI_CallAnyMethodV (JNIEnv *env, jobject obj, jclass klass, ...@@ -560,6 +560,10 @@ _Jv_JNI_CallAnyMethodV (JNIEnv *env, jobject obj, jclass klass,
jvalue args[arg_types->length]; jvalue args[arg_types->length];
array_from_valist (args, arg_types, vargs); 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; jvalue result;
jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id, jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor, style == constructor,
...@@ -604,6 +608,10 @@ _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass, ...@@ -604,6 +608,10 @@ _Jv_JNI_CallAnyMethodA (JNIEnv *env, jobject obj, jclass klass,
_Jv_GetTypesFromSignature (id, decl_class, _Jv_GetTypesFromSignature (id, decl_class,
&arg_types, &return_type); &arg_types, &return_type);
// For constructors we need to pass the Class we are instantiating.
if (style == constructor)
return_type = klass;
jvalue result; jvalue result;
jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id, jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor, style == constructor,
...@@ -636,6 +644,10 @@ _Jv_JNI_CallAnyVoidMethodV (JNIEnv *env, jobject obj, jclass klass, ...@@ -636,6 +644,10 @@ _Jv_JNI_CallAnyVoidMethodV (JNIEnv *env, jobject obj, jclass klass,
jvalue args[arg_types->length]; jvalue args[arg_types->length];
array_from_valist (args, arg_types, vargs); 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, jthrowable ex = _Jv_CallAnyMethodA (obj, return_type, id,
style == constructor, style == constructor,
arg_types, args, NULL); arg_types, args, NULL);
...@@ -804,7 +816,11 @@ _Jv_JNI_NewObjectV (JNIEnv *env, jclass klass, ...@@ -804,7 +816,11 @@ _Jv_JNI_NewObjectV (JNIEnv *env, jclass klass,
{ {
JvAssert (klass && ! klass->isArray ()); JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>") 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, return _Jv_JNI_CallAnyMethodV<jobject, constructor> (env, NULL, klass,
id, args); id, args);
} }
...@@ -814,7 +830,10 @@ _Jv_JNI_NewObject (JNIEnv *env, jclass klass, jmethodID id, ...) ...@@ -814,7 +830,10 @@ _Jv_JNI_NewObject (JNIEnv *env, jclass klass, jmethodID id, ...)
{ {
JvAssert (klass && ! klass->isArray ()); JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>") 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; va_list args;
jobject result; jobject result;
...@@ -833,7 +852,11 @@ _Jv_JNI_NewObjectA (JNIEnv *env, jclass klass, jmethodID id, ...@@ -833,7 +852,11 @@ _Jv_JNI_NewObjectA (JNIEnv *env, jclass klass, jmethodID id,
{ {
JvAssert (klass && ! klass->isArray ()); JvAssert (klass && ! klass->isArray ());
JvAssert (! strcmp (id->name->data, "<init>") 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, return _Jv_JNI_CallAnyMethodA<jobject, constructor> (env, NULL, klass,
id, args); id, args);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment