JDK-8314080 : JNI spec: clarify NewWeakGlobalRef handling of weak global references
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-08-10
  • Updated: 2023-08-14
  • Resolved: 2023-08-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 masterFixed
Related Reports
Relates :  
Description
The spec for NewWeakGlobalRef initially states:

Returns NULL if obj refers to null, or if obj was a weak global reference, or if the VM runs out of memory.

However, the actual "returns" section states:

May return NULL if:

    obj refers to null
    the system has run out of memory
    obj was a weak global reference and has already been garbage collected

The part "and has already been garbage collected" is missing from the initial text and may cause confusion.

The "returns" section was updated by JDK-8188066 but the expanded information was not also added to the main text.
Comments
For consistency with NewGlobalRef we remove the partial "Returns ..." sentences from the main text of NewLocalRef and NewWeakGlobalRef; relying on the RETURNS and THROWS sections to provide the specified behaviour.
13-08-2023