I have a program that reliably deadlocks when run on JDK 17, but not on JDK 16 
(although that may be due to timing differences, so it may not imply a new bug).

It’s a fairly complicated situation.

On the AWT thread, my program calls native code that displays a native file 
dialog. My Java code sets up a secondary run loop. The native code blocks on 
JNFRunLoop performOnMainThread to create the native file dialog.

The AppKit implementation of the file dialog calls Java to get accessibility 
information. This sets up a run loop on the main thread and upcalls to Java. I 
presume this posts an AWT event.

Before the AWT secondary run loop can process the request for accessibility 
information, it runs an invocation event (previously posted by a timer) that 
calls native code. This native code blocks attempting to perform code on the 
main thread using JNFRunLoop. Apparently, this request is never processed and 
the AWT thread remains blocked forever.

If I change this latter native code to perform the main thread operation 
without blocking, there is no deadlock and all is fine.

But I have encountered other deadlocks (not reliably repeatable) where this 
option is not available. Therefore, I would like to understand why this 
deadlock is happening.

With run loops on both threads, what would cause the deadlock?

[Question: does JDK 17 and JNFRunLoop use the same NSString to identify the 
java run loop mode? If not, might that matter?]

I would appreciate any suggestions of what might be going wrong or how to track 
it down.

  Alan

Reply via email to