[kaffe] Implementing NewWeakGlobalRef
robilad at kaffe.org
Mon Jun 27 06:57:45 PDT 2005
Guilhem Lavaux wrote:
> We are only missing two functions in our JNI 1.4 implementation:
> NewWeakGlobalRef and DeleteWeakGlobalRef. These are intended as
> lightweight weak global reference builders in the VM. They create weak
> object reference from any object reference. From the documentation, it
> looks the weak reference are normal objects.
> My first impression is that to build a weak reference we have to hide
> the real object reference in a fixed allocated memory which will not be
> walked by the GC. However doing this we cannot use this reference as a
> good parameter for all other JNI functions.
> So, I am proposing to add an unvailing macro which will detect and
> decode weak reference. This macro should be called in all functions and
> on all parameters that represent object references (except array entries
> I think).
> This will however add some cost to each JNI call but I don't yet see how
> to implement it another cheap way.
> Any other idea ?
Sounds good to me. gcj calls a similar inline funciton in jni.cc unwrap,
maybe we culd reuse the convention?
More information about the kaffe