aboutsummaryrefslogtreecommitdiff
path: root/libjava/jni.cc
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-02-16 00:07:34 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-02-16 00:07:34 +0000
commitd348bda453c2ec3ebe67ff3208822e040960ccb6 (patch)
treefd8526541777f72d0a207a77149193b5171b7e75 /libjava/jni.cc
parentf295bdb5eb37ae58628d68dd74d7067591ee29ee (diff)
downloadgcc-d348bda453c2ec3ebe67ff3208822e040960ccb6.zip
gcc-d348bda453c2ec3ebe67ff3208822e040960ccb6.tar.gz
gcc-d348bda453c2ec3ebe67ff3208822e040960ccb6.tar.bz2
resolve.cc (ncode): Set args_raw_size.
* resolve.cc (ncode): Set args_raw_size. Compute jni_cif and jni_arg_types. (init_cif): Added `rtype_p' argument. * include/java-interp.h (class _Jv_MethodBase): Added args_raw_size. (class _Jv_InterpMethod): Removed args_raw_size. (class _Jv_JNIMethod): Added jni_cif and jni_arg_types fields. * jni.cc (call): Pass JNIEnv and (for static methods only) the class pointer as well as the ordinary arguments. From-SVN: r31995
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r--libjava/jni.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc
index 0d78b32..26f3b04 100644
--- a/libjava/jni.cc
+++ b/libjava/jni.cc
@@ -1323,7 +1323,7 @@ mangled_name (jclass klass, _Jv_Utf8Const *func_name,
// This function is the stub which is used to turn an ordinary (CNI)
// method call into a JNI call.
void
-_Jv_JNIMethod::call (ffi_cif *cif, void *ret, ffi_raw *args, void *__this)
+_Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this)
{
_Jv_JNIMethod* _this = (_Jv_JNIMethod *) __this;
@@ -1372,9 +1372,24 @@ _Jv_JNIMethod::call (ffi_cif *cif, void *ret, ffi_raw *args, void *__this)
}
}
+ JvAssert (_this->args_raw_size % sizeof (ffi_raw) == 0);
+ ffi_raw real_args[2 + _this->args_raw_size / sizeof (ffi_raw)];
+ int offset = 0;
+
+ // First argument is always the environment pointer.
+ real_args[offset++].ptr = &env;
+
+ // For a static method, we pass in the Class. For non-static
+ // methods, the `this' argument is already handled.
+ if ((_this->self->accflags & java::lang::reflect::Modifier::STATIC))
+ real_args[offset++].ptr = _this->defining_class;
+
+ // Copy over passed-in arguments.
+ memcpy (&real_args[offset], args, _this->args_raw_size);
+
// The actual call to the JNI function.
- // FIXME: if this is a static function we must include the class!
- ffi_raw_call (cif, (void (*) (...)) _this->function, ret, args);
+ ffi_raw_call (&_this->jni_cif, (void (*) (...)) _this->function,
+ ret, real_args);
do
{