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

Clarify invalid method and field ID in JNI specification

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 18
    • hotspot
    • None
    • behavioral
    • minimal
    • This is simple clarification in the design section of the specification and has no impact on any implementation.
    • Other

      Summary

      Clarify that invalid field and Method ID's may not be passed to JNI functions.

      Problem

      Programmers will sometimes create field or method ID's that outlive the class that they were associated with and continue to try to use them when they are no longer valid. The design section of the specification does not strongly enough indicate that you should not do this.

      Solution

      Insert the following bold text to the existing text:

      After the class is unloaded, the method or field ID becomes invalid and may not be passed to any function taking such an ID.

      Specification

       A field or method ID does not prevent the VM from unloading the class from which the ID has been derived. After the class is unloaded, the method or field
      -ID becomes invalid. The native code, therefore, must make sure to:
      +ID becomes invalid and may not be passed to any function taking such an ID.
      +The native code, therefore, must make sure to:

            dholmes David Holmes
            jiangli Jiangli Zhou
            Harold Seigel (Inactive), Jiangli Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: