RFR: 8313874 - JNI NewWeakGlobalRef throws exception for null arg
Stefan Karlsson
stefank at openjdk.org
Tue Aug 8 12:40:31 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.)
I see that the spec further down says:
`obj was a weak global reference and has already been garbage collected`
So, it is just the first `obj was a weak global reference` occurrence that is ill-worded.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15188#issuecomment-1669531678
More information about the hotspot-dev
mailing list