RFR: 8359266: Delete the usage of AppContext in the GraphicsDevice
Sergey Bylokhov
serb at openjdk.org
Thu Jun 26 01:54:39 UTC 2025
On Wed, 25 Jun 2025 14:59:53 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> This PR removes the usage of AppContext from the GraphicsDevice class. The original use case was to store the full-screen window in some AppContext, which was necessary in the context of plugin/appletviewer environments. However, there is now effectively only one main AppContext, so this indirection can be eliminated.
>>
>> Notes: GraphicsDevice provides two methods for handling full-screen windows:
>> - setFullScreenWindow() is considered thread-safe, as all platform-specific implementations override it with synchronized methods ([example](https://github.com/openjdk/jdk/blob/23e1e2ff4a4a75ec268c7925fb98d6b96a01bbcf/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java#L226)).
>> - getFullScreenWindow() previously relied on AppContext for thread-safety. After removing AppContext, this method is now made thread-safe by declaring the fullScreenWindow field as volatile. This change has been validated by an added test.
>
> test/jdk/java/awt/GraphicsDevice/FullScreenWindowRace.java line 55:
>
>> 53: gd.setFullScreenWindow(window);
>> 54:
>> 55: thread.join(15000);
>
> Does it make sense to reduce the waiting time? The thread should exit much quicker than 15 seconds, 5 second should be plenty enough.
It will stop waiting immediately if the thread completes execution, but just to be sure we do not get any false positive results when the test fails on slow systems, I added this timeout. So if it fails it will be a real bug.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25818#discussion_r2167930721
More information about the client-libs-dev
mailing list