RFR: 8313874 - JNI NewWeakGlobalRef throws exception for null arg

Oli Gillespie ogillespie at openjdk.org
Tue Aug 8 13:20:57 UTC 2023


On Tue, 8 Aug 2023 10:40:30 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.)

Updated the null check and moved the test to an existing file, thanks.

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

PR Comment: https://git.openjdk.org/jdk/pull/15188#issuecomment-1669594535


More information about the hotspot-dev mailing list