RFR: 8255248: NullPointerException in JFXPanel due to race condition in HostContainer [v5]
Kevin Rushforth
kcr at openjdk.org
Wed Nov 19 14:39:51 UTC 2025
On Wed, 19 Nov 2025 12:34:01 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 974:
>>
>>> 972: getScene().getFocusOwner() != null &&
>>> 973: getScene().getFocusOwner().isFocused()) {
>>> 974: hStagePeer.focusUngrab();
>>
>> This can be reverted. `stagePeer` is only accessed on the FX thread.
>
> `stagePeer` is accessed in `processMouseEvent`, `sendResizeEventToFX`, `sendMoveEventToFX`, `sendFocusEventToFX `in EDT so I did that.
> But it seems in this particular method, it is only accessed in FX thread as is mentioned so reverted..
Right, I only meant this specific instance (and the usage later on in this same lambda). It looks good now.
>> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 1078:
>>
>>> 1076: stagePeer = embeddedStage;
>>> 1077: var hStagePeer = stagePeer;
>>> 1078: if (hStagePeer == null) {
>>
>> If this is always invoked from the FX thread, you don't need to locally capture the peers.
>
> but down below it is accessed in EDT so I did the local capture
Yes, you are right.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2542119249
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2542126656
More information about the openjfx-dev
mailing list