RFR: 8313874 - JNI NewWeakGlobalRef throws exception for null arg

Oli Gillespie ogillespie at openjdk.org
Tue Aug 8 10:47:50 UTC 2023


According to the JNI spec for NewWeakGlobalRef:

> Returns NULL if obj refers to null, or if obj was a weak global reference, or if the VM runs out of memory. If the VM runs out of memory, an OutOfMemoryError will be thrown.

The current behaviour is that `NewWeakGlobalRef(nullptr)` throws an OutOfMemoryError, which it should not.

(Thanks @dholmes-ora for confirming the issue and suggesting a fix.)

-------------

Commit messages:
 - 8313874 - JNI NewWeakGlobalRef throws exception for null arg

Changes: https://git.openjdk.org/jdk/pull/15188/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15188&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8313874
  Stats: 42 lines in 3 files changed: 41 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/15188.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15188/head:pull/15188

PR: https://git.openjdk.org/jdk/pull/15188


More information about the hotspot-dev mailing list