On Thu, 28 May 2026 19:37:19 GMT, Phil Race <[email protected]> wrote:

>> Alexander Zvegintsev has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   explanatory comment
>
> src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 
> line 628:
> 
>> 626:         }
>> 627:     }
>> 628: 
> 
> Is it intentional that if objPtr == NULL that we release the jni ref to the 
> old java device and set javaDevice = NULL ?
> It would make sense if this is the intended way to clear the javaDevice but I 
> don't have the whole picture yet. If intentional an explanatory comment would 
> help.

Yes, it is intentional. I've updated the comment.

> src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 
> line 649:
> 
>> 647:         env->DeleteWeakGlobalRef(javaDevice);
>> 648:     }
>> 649:     javaDevice = device->javaDevice;
> 
> Why don't we need a new JNI ref here ?

Because this is a transfer, not creating an additional reference.
`device->javaDevice` is already a JNI weak global ref created earlier by 
`NewWeakGlobalRef` in `SetJavaDevice`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31238#discussion_r3320543081
PR Review Comment: https://git.openjdk.org/jdk/pull/31238#discussion_r3320570513

Reply via email to