JNI global refs

Tom Tromey tromey@redhat.com
Thu Jun 28 11:48:00 GMT 2001


>>>>> "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


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /