JNI patches

Tom Tromey tromey@redhat.com
Mon Apr 2 15:35:00 GMT 2001

Per> I am not convinced this is needed.  Does anything in the JNI
Per> prohibit the following implementation:

Per> * Locals refs and global refs are the same.  When either refers
Per> to an object, the ref is just a pointer to the Java object.
Per> * NewGlobalRef is an identify operation.
Per> * DeleteLocalRef and DeleteGlobalRef do nothing.

We can't do this because, as has been pointed out, the GC won't scan
malloc()d areas.

However, I think it is ok to have local and global refs be the same.
That is what I implemented in jni.cc.  This implementation isn't
perfect (in fact it is ugly), but I think it is ok.

I imagine it is an error for a program to try to use DeleteLocalRef to
free a global ref.  However as far as I can tell we aren't required to
diagnose this.

OTOH I'm not really opposed to Marcus' patch.  I think it would be
useful if we had a way to build the JNI support with a lot of checking
built in.  That would make it easier to write JNI programs.  His patch
could help us do that.

Marcus, before this can go in we'll have to get paperwork and such
from you.  Do you have gcc/gcj paperwork filed already?

The smaller patch I am going to check in.  I think I must have assumed
that the jobject specialization would also handle jclass, but of
course it doesn't.


More information about the Java mailing list