On Thu, 19 Jun 2025 19:45:48 GMT, Alexey Ivanov <aiva...@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. > > src/java.desktop/share/classes/java/awt/GraphicsDevice.java line 306: > >> 304: } >> 305: // Set the full screen window >> 306: synchronized (fsAppContextLock) { > > A `synchronized` block has stronger memory consistency guarantees than a > `volatile` modifier. > > Did you consider leaving the synchronized block but removing the usage of > `AppContext`? What do you mean by stronger in this use case? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25818#discussion_r2157863506