aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libjava/ChangeLog6
-rw-r--r--libjava/java/lang/reflect/natMethod.cc43
2 files changed, 48 insertions, 1 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index fdcf21c..c6561ab 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,9 @@
+2002-02-24 Jeff Sturm <jsturm@one-point.com>
+
+ * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA):
+ Define ffi_result union for ffi_call result. Cast
+ ffi_result members to jvalue.
+
2002-02-23 Alexandre Oliva <aoliva@redhat.com>
* Makefile.in, gcj/Makefile.in, include/Makefile.in: Rebuilt.
diff --git a/libjava/java/lang/reflect/natMethod.cc b/libjava/java/lang/reflect/natMethod.cc
index 1fab48a..e11e5c36 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;