<AWT Dev> RFR: 8260616: Removing remaining JNF dependencies in the java.desktop module [v3]

Sergey Bylokhov serb at openjdk.java.net
Tue Feb 2 22:11:48 UTC 2021

On Tue, 2 Feb 2021 21:18:42 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> We are just specifying an additional run mode for JDK internal use.
>> It means that when we are saying to process only events for that mode, then only those will be processed.
>> And it is used only for nested event loops.
>> Nothing eternal should be assuming AWT uses JNF at all, never mind in a particular way.
>> There is a special case for FX but I don't see a problem.
>> If you look at Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl
>> there's a variable "inAWT".
>>          isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode) ... ]];
>> This is specified as
>>         inAWT = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
>>             @Override
>>             public Boolean run() {
>>                 return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false"));
>>             }
>>         });
>>     }
>> So generally FX doesn't care, and is ignorant of this new mode.
>> Unless you set that property to true, in which case AWT use the  NSDefaultRunLoopMode and so again FX is unaffected.
>> Nothing in the FX sources goes anywhere near JNF .. or has a reference to the special mode.
>> Bottom line I don't see it being affected. 
>> I'll check with Kevin but also Gerard had a lot to do with the creation of the current FX toolkit.
> I ran some tests embedding JavaFX into Swing and vice versa both with and without `-Djavafx.embed.singleThread=true` and I don't see any regression in behavior.

I am mostly worried about the usage of JNF by someone else's native code, as far as I understand it could be "broken" now. But it is good that FX does not use it.

BTW looks like all comments like  "// AWT_THREADING Safe (AWTRunLoop)" could be removed now.


PR: https://git.openjdk.java.net/jdk/pull/2305

More information about the awt-dev mailing list