diff options
author | jsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-02-24 17:55:44 +0000 |
---|---|---|
committer | jsturm <jsturm@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-02-24 17:55:44 +0000 |
commit | 657e12d69919e2f84d58ac74055a97d3d6b0c0dc (patch) | |
tree | fc1dd755b6284db55539e69c6e09dec22014b349 /libjava/java | |
parent | fed8d18da6d8bed88800208cbcf864e9fc7c76c6 (diff) | |
download | gcc-657e12d69919e2f84d58ac74055a97d3d6b0c0dc.tar.gz |
* java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA):
Define ffi_result union for ffi_call result. Cast
ffi_result members to jvalue.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50007 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/reflect/natMethod.cc | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc index 1fab48ab311..e11e5c3677c 100644 --- a/libjava/java/lang/reflect/natMethod.cc +++ b/libjava/java/lang/reflect/natMethod.cc @@ -423,9 +423,17 @@ _Jv_CallAnyMethodA (jobject obj, Throwable *ex = NULL; + union + { + ffi_arg i; + jlong l; + jfloat f; + jdouble d; + } ffi_result; + try { - ffi_call (&cif, (void (*)()) meth->ncode, result, values); + ffi_call (&cif, (void (*)()) meth->ncode, &ffi_result, values); } catch (Throwable *ex2) { @@ -436,6 +444,39 @@ _Jv_CallAnyMethodA (jobject obj, ex = new InvocationTargetException (ex2); } + // Since ffi_call returns integer values promoted to a word, use + // a narrowing conversion for jbyte, jchar, etc. results. + // Note that boolean is handled either by the FFI_TYPE_SINT8 or + // FFI_TYPE_SINT32 case. + switch (rtype->type) + { + case FFI_TYPE_VOID: + break; + case FFI_TYPE_SINT8: + result->b = (jbyte)ffi_result.i; + break; + case FFI_TYPE_SINT16: + result->s = (jshort)ffi_result.i; + break; + case FFI_TYPE_UINT16: + result->c = (jchar)ffi_result.i; + break; + case FFI_TYPE_SINT32: + result->i = (jint)ffi_result.i; + break; + case FFI_TYPE_SINT64: + result->j = (jlong)ffi_result.l; + break; + case FFI_TYPE_FLOAT: + result->f = (jfloat)ffi_result.f; + break; + case FFI_TYPE_DOUBLE: + result->d = (jdouble)ffi_result.d; + break; + default: + JvFail ("Unknown ffi_call return type"); + break; + } if (is_constructor) result->l = obj; |