On Mon, 9 Nov 2026 16:35:04 GMT, Andy Goryachev <[email protected]> wrote:
>> This PR fixes some rare NPEs I saw some users encounter when a window was >> hidden. The tests should cover all those potential issues and should fail >> without this PR and succeed with this PR. >> >> I originally only wanted to fix the 1. NPE because that actually happened to >> some users, but during that I realized that the 2. NPE can also be provoked >> if you write a listener that just hides the window on some window events. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassWindowEventHandler.java > line 58: > >> 56: // Read the listener once as it can be cleared while this event >> is >> 57: // being processed, e.g. if an application listener hides the >> stage >> 58: TKStageListener listener = stage.stageListener; > > should the same treatment (a local var) be applied to GlassStage:173 ? > > also, do we know whether `GlassStage.stageListener` is accessed from multiple > threads and therefore be declared `volatile`? I don't think so, nothing runs between the null check and the call in GlassStage. Also, if I see that correctly, everything runs on the FX application thread, so volatile isn't needed ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2364#discussion_r4515457353
