JDK-8275087 : Clarify invalid method and field ID in JNI specification
  • Type: CSR
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 18
  • Submitted: 2021-10-12
  • Updated: 2021-10-15
  • Resolved: 2021-10-15
Related Reports
CSR :  
Description
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:


Comments
Moving to Approved.
15-10-2021