RFR: 8313874 - JNI NewWeakGlobalRef throws exception for null arg [v2]
David Holmes
dholmes at openjdk.org
Tue Aug 8 21:06:33 UTC 2023
On Tue, 8 Aug 2023 12:22:38 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> src/hotspot/share/prims/jni.cpp line 2879:
>>
>>> 2877: Handle ref_handle(thread, JNIHandles::resolve(ref));
>>> 2878: jweak ret = JNIHandles::make_weak_global(ref_handle, AllocFailStrategy::RETURN_NULL);
>>> 2879: if (ret == nullptr && ref_handle != nullptr) {
>>
>> That isn't how you check a Handle for null content - you need `!ref_handle.is_null()`.
>
> even better would be `ref_handle.not_null()`. Though I think the comparison does work.
Yes it seems that some implicit Handle conversions were removed at some point which now makes direct comparison to `nullptr` allowable - somewhat obsolescing the `is_null()/not_null()` helper methods.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15188#discussion_r1287687902
More information about the hotspot-dev
mailing list