Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4327557

Semantics of JNI weak references need to be clearly documented

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • docs
    • fcs
    • generic
    • generic


      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.

            asommere Alan Sommerer (Inactive)
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: