This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: jni fixlet
Tom Tromey wrote:
"Marco" == Marco Trudel <mtrudel@gmx.ch> writes:
Marco> Attached the version with the comment on the second line.
A few formatting nits... it is a little more usual not to put comments
on the same line as code (except for something like a table). Also
there is a space between 'if' and '('. Finally ChangeLog entries have
a precise formatting, including a tab before the '*'.
So less code and so much formatting issues... Sorry about that. I never
got around to read the GCC coding conventions. Where do I find them?
It is a little silly that a 3 line patch can result in so much
conversation. But, that's GCC for you :-}
Actually the common agreement was that I run a "make check" with it and
create a regression test. Well, then I'll do that for the next patch (at
least as long as they're not win32 only).
Here's what I'm checking in.
Thank you for your time!
Do you know whether we need this for local refs as well?
Yes and No. It also has to ignore NULL pointers, but this is done
already. Coincidence maybe ;-)
I wrote a little testcase for both. Maybe you want to check them in as
regression tests...
thanks again
Marco
Tom
Index: ChangeLog
from Marco Trudel <mtrudel@gmx.ch>
* jni.cc (_Jv_JNI_DeleteWeakGlobalRef): Check for NULL objects.
Index: jni.cc
===================================================================
--- jni.cc (revision 121691)
+++ jni.cc (working copy)
@@ -1750,6 +1750,10 @@
void JNICALL
_Jv_JNI_DeleteWeakGlobalRef (JNIEnv *, jweak obj)
{
+ // JDK compatibility.
+ if (obj == NULL)
+ return;
+
using namespace gnu::gcj::runtime;
JNIWeakRef *ref = reinterpret_cast<JNIWeakRef *> (obj);
unmark_for_gc (ref, global_ref_table);
#include <jni.h>
JNIEXPORT void JNICALL Java_DeleteRefTest_runTest(JNIEnv *env, jclass cl, jobject obj)
{
// both mustn't fail
(*env)->DeleteWeakGlobalRef(env, NULL);
(*env)->DeleteLocalRef(env, NULL);
}
public class DeleteRefTest
{
public static void main(String[] args)
{
System.loadLibrary("deleteRefTest");
runTest(null);
}
private static native void runTest(Object o);
}