RFR: 8190329: [macos] Swing InterOp Platform.exit() crash

Phil Race prr at openjdk.org
Fri Aug 23 18:00:03 UTC 2024


On Fri, 23 Aug 2024 09:17:43 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> The testcase calls Platform.exit before the dialog is made visible but
> on macOS, JavaFX takes over the AppKit thread and uses that as the FX application thread. As part of the FX platform shutdown process, it detaches that thread from the JVM. This means that the AppKit thread is no longer available to Java processes
> so AWT crashes when it ties to access appkit thread.
> Fix is made to check if the thread has been detached for move-resize notification event before proceeding..

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m line 640:

> 638:     if (ret == JNI_EDETACHED) {
> 639:         return;
> 640:     }

This seems like a completely arbitrary location in the AWT code for a test of something that would seem completely unexpected.
Can you PROVE that this is the only place that this will ever be needed ?
And if you can't, this isn't the right fix.
If you can it needs some comments.

Also : does AWT detach the AppKit thread from the VM on shutdown ?
IF not why does FX have to do it ? If it does, then could FX also crash if FX is embedded in an AWT app.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20688#discussion_r1729333420


More information about the client-libs-dev mailing list