This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: JNI global refs
- To: mgd at swarm dot org (Marcus G. Daniels)
- Subject: Re: JNI global refs
- From: Tom Tromey <tromey at redhat dot com>
- Date: 28 Jun 2001 13:07:31 -0600
- Cc: java at gcc dot gnu dot org
- References: <m2lmmed8ct.fsf@marcus.santafe.edu>
- Reply-To: tromey at redhat dot com
>>>>> "Marcus" == Marcus G Daniels <mgd@swarm.org> writes:
Marcus> I think the pointers returned by JNI NewGlobalRef be allocated
Marcus> using GC_malloc_uncollectable. The way it is now, if you
Marcus> store one of these in malloced space (as opposed to
Marcus> GC_malloced space) the garbage collector may come along and
Marcus> think it is free to take it.
I don't understand.
In our implementation the value returned by NewGlobalRef is the same
as the value you pass in. However, in order to ensure that the object
is not GC'd, we stash it in a hash table which is scanned by the GC.
That hash table uses (eww) reference counts to ensure that the
object's entry is not cleared before all the global references to it
have been deleted.
I could easily believe that we're seeing some bug in this code. In
general JNI has not been stress tested (except by you :-). However, I
don't understand your proposed change. Where would we put the
GC_malloc_uncollectable?
Tom