diff options
author | Tom Tromey <tromey@redhat.com> | 2005-11-29 18:34:58 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2005-11-29 18:34:58 +0000 |
commit | 3141ed0fe01e5e5cd726dc6410f49a0323361d94 (patch) | |
tree | 5ba6f0f10a37c9d1c36de0493f0563ef6f583cad /libjava/jni.cc | |
parent | 4311c8e54c31efed7aa9aaef244a4ac93fbf96d2 (diff) | |
download | gcc-3141ed0fe01e5e5cd726dc6410f49a0323361d94.zip gcc-3141ed0fe01e5e5cd726dc6410f49a0323361d94.tar.gz gcc-3141ed0fe01e5e5cd726dc6410f49a0323361d94.tar.bz2 |
re PR java/18278 (JNI functions cannot return a weak reference)
gcc/java:
PR java/18278:
* expr.c (build_jni_stub): Unwrap the return value.
* java-tree.h (soft_unwrapjni_node): New define.
(enum java_tree_index): Added JTI_SOFT_UNWRAPJNI_NODE.
* decl.c (java_init_decl_processing): Initialize
soft_unwrapjni_node.
libjava:
PR java/18278:
* testsuite/libjava.jni/pr18278.out: New file.
* testsuite/libjava.jni/pr18278.c: New file.
* testsuite/libjava.jni/pr18278.java: New file.
* include/jvm.h (_Jv_UnwrapJNIweakReference): Declare.
* jni.cc (_Jv_UnwrapJNIweakReference): New function.
(call): Unwrap return value if needed.
From-SVN: r107676
Diffstat (limited to 'libjava/jni.cc')
-rw-r--r-- | libjava/jni.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libjava/jni.cc b/libjava/jni.cc index 13bb12c..fd82706 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -226,6 +226,12 @@ unwrap (T *obj) return reinterpret_cast<T *> (wr->get ()); } +jobject +_Jv_UnwrapJNIweakReference (jobject obj) +{ + return unwrap (obj); +} + static jobject JNICALL @@ -2304,6 +2310,13 @@ _Jv_JNIMethod::call (ffi_cif *, void *ret, ffi_raw *args, void *__this) ret, real_args); #endif + // We might need to unwrap a JNI weak reference here. + if (_this->jni_cif.rtype == &ffi_type_pointer) + { + _Jv_value *val = (_Jv_value *) ret; + val->object_value = unwrap (val->object_value); + } + if (sync != NULL) _Jv_MonitorExit (sync); |