On Fri, 10 Nov 2023 21:26:21 GMT, Sergey Bylokhov <[email protected]> wrote:

>> It can be null if the NSApplication was created by code outside of AWT. 
>> Specifically, in the case of an FX or SWT toolkit, but in theory a native 
>> application using JAWT could do this.
>> 
>> In practice, since we haven't even seen a crash as a result of this, I doubt 
>> that this code is ever called if AWT isn't running the event loop and hasn't 
>> installed their delegate.
>
> To access any native code in AWT the app should initially init the LWCToolkit 
> which sets that application delegate if it is not set already. Do we know how 
> the FX can bypass that initialization?

@mrserb Based on testing so far (tested for following cases - Pure AWT/Swing, 
Pure FX, Swing components embedded in FX window and FX components embedded in 
Swing window), there hasn't been a scenario where the shared delegate has been 
null even in  FX embedded case. As @prrace, @kevinrushforth mentioned earlier, 
I was thinking of the case where NSApp is created by code outside of AWT and 
perhaps it fails to install its delegate. The present null checks were added 
keeping the above scenario in mind.

I'll do some more testing and get back to you on your question - _"if shared 
delegate can be null at the above locations"_

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16569#discussion_r1393059684

Reply via email to