RFR: 8313874 - JNI NewWeakGlobalRef throws exception for null arg [v2]

Kim Barrett kbarrett at openjdk.org
Tue Aug 8 17:12:31 UTC 2023


On Tue, 8 Aug 2023 13:20:55 GMT, Oli Gillespie <ogillespie at openjdk.org> wrote:

>> 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.)
>
> Oli Gillespie has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review feedback
>   
>   Move test case to existing test, use .not_null() for null check.

Looks good.

It's weird that NewWeakGlobalRef throws on OOM, but NewGlobalRef doesn't.  But that's
what the spec says.

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

Marked as reviewed by kbarrett (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15188#pullrequestreview-1567783874


More information about the hotspot-dev mailing list