[kaffe] Implementing NewWeakGlobalRef

Guilhem Lavaux guilhem at kaffe.org
Mon Jun 27 01:44:47 PDT 2005


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 ?



More information about the kaffe mailing list