From 426f02615d7e0380b7153e58270cb791ccd380f4 Mon Sep 17 00:00:00 2001 From: tromey Date: Tue, 27 Jun 2006 15:33:24 +0000 Subject: [PATCH] PR libgcj/28178: * jni.cc (_Jv_JNI_DeleteLocalRef): Ignore null argument. (_Jv_JNI_DeleteGlobalRef): Likewise. * testsuite/libjava.jni/PR28178.java: New file. * testsuite/libjava.jni/PR28178.c: New file. * testsuite/libjava.jni/PR28178.out: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115034 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 9 +++++++++ libjava/jni.cc | 11 +++++++++++ libjava/testsuite/libjava.jni/PR28178.c | 10 ++++++++++ libjava/testsuite/libjava.jni/PR28178.java | 15 +++++++++++++++ libjava/testsuite/libjava.jni/PR28178.out | 0 5 files changed, 45 insertions(+) create mode 100644 libjava/testsuite/libjava.jni/PR28178.c create mode 100644 libjava/testsuite/libjava.jni/PR28178.java create mode 100644 libjava/testsuite/libjava.jni/PR28178.out diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d87c1b9bad9..e6d1bbb69ac 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,12 @@ +2006-06-27 Tom Tromey + + PR libgcj/28178: + * jni.cc (_Jv_JNI_DeleteLocalRef): Ignore null argument. + (_Jv_JNI_DeleteGlobalRef): Likewise. + * testsuite/libjava.jni/PR28178.java: New file. + * testsuite/libjava.jni/PR28178.c: New file. + * testsuite/libjava.jni/PR28178.out: New file. + 2006-06-26 Keith Seitz * include/posix-threads.h: Fix coding style aberrations from diff --git a/libjava/jni.cc b/libjava/jni.cc index 19539c7714a..67ba8fa4941 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -248,6 +248,12 @@ _Jv_JNI_DeleteGlobalRef (JNIEnv *, jobject obj) { // This seems weird but I think it is correct. obj = unwrap (obj); + + // NULL is ok here -- the JNI specification doesn't say so, but this + // is a no-op. + if (! obj) + return; + unmark_for_gc (obj, global_ref_table); } @@ -259,6 +265,11 @@ _Jv_JNI_DeleteLocalRef (JNIEnv *env, jobject obj) // This seems weird but I think it is correct. obj = unwrap (obj); + // NULL is ok here -- the JNI specification doesn't say so, but this + // is a no-op. + if (! obj) + return; + for (frame = env->locals; frame != NULL; frame = frame->next) { for (int i = 0; i < frame->size; ++i) diff --git a/libjava/testsuite/libjava.jni/PR28178.c b/libjava/testsuite/libjava.jni/PR28178.c new file mode 100644 index 00000000000..17e730a1c36 --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR28178.c @@ -0,0 +1,10 @@ +#include + +void +Java_PR28178_m (JNIEnv *env, jclass ignore) +{ + (*env)->DeleteLocalRef(env, NULL); + (*env)->DeleteGlobalRef(env, NULL); +} + + diff --git a/libjava/testsuite/libjava.jni/PR28178.java b/libjava/testsuite/libjava.jni/PR28178.java new file mode 100644 index 00000000000..f8d7b904ccd --- /dev/null +++ b/libjava/testsuite/libjava.jni/PR28178.java @@ -0,0 +1,15 @@ +// Regression test for PR 28178. + +public class PR28178 +{ + static { + System.loadLibrary("PR28178"); + } + + public static native void m(); + + public static void main(String[] args) + { + m(); + } +} diff --git a/libjava/testsuite/libjava.jni/PR28178.out b/libjava/testsuite/libjava.jni/PR28178.out new file mode 100644 index 00000000000..e69de29bb2d -- 2.11.4.GIT