The JNI Enhancements document (
http://java.sun.com/products/jdk/1.3/docs/guide/jni/jni-12.html
)
needs to be updated to clearly explains the semantics of JNI
weak references :-
(a) Current spec does not indicate that JNI doesn't provide any
guarantees subsequent to a test using IsSameObject and thus the object
can be collected at any time. The developer needs to use NewLocalRef or
NewGlobalRef to test the weak ref (returns NULL if collected) and hold
on to the reference if he/she wants to make sure it's not collected
between the time test is made and the time the object is used.
(b) Current spec does not indicate that JNI weak global refs are
cleared last of all the reference types (soft/weak/final/phantom)
and it does not indicate if JNI weak refs can be cleared prior to
running the finalizers. (viz. finalizer which invokes native
method than uses JNI weak ref that is reference to Java object).
(c) Clearing of JNI weak references is not specified in the
presence of a true Concurrent GC.