Skip to content

Move setting of awtAppClassName from MainWindow to Main#9314

Draft
neilcsmith-net wants to merge 1 commit intoapache:masterfrom
neilcsmith-net:splash-wm-class
Draft

Move setting of awtAppClassName from MainWindow to Main#9314
neilcsmith-net wants to merge 1 commit intoapache:masterfrom
neilcsmith-net:splash-wm-class

Conversation

@neilcsmith-net
Copy link
Copy Markdown
Member

Move the setting of awtAppClassName for XToolkit into Main so that it is set before splash and import dialogs are created. This should fix issues with duplicate dock icons caused by incorrect WM_CLASS derived from this field value that need to be worked around in the various package builds.

Follow up to discussion in #9303 Draft for now. Should probably wait for and rebase on that change.

Move the setting of awtAppClassName for XToolkit into Main so that
it is set before splash and import dialogs are created. This fixes
issues with duplicate dock icons caused by incorrect WM_CLASS
derived from this field value.
@neilcsmith-net neilcsmith-net added Platform [ci] enable platform tests (platform/*) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Mar 31, 2026
@neilcsmith-net neilcsmith-net marked this pull request as draft March 31, 2026 17:34
@neilcsmith-net neilcsmith-net added this to the NB30 milestone Mar 31, 2026
Comment on lines +373 to +378
if (xtoolkit.getName().equals("sun.awt.X11.XToolkit")) { //NOI18N
// TODO those add --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED

//#183739 / JDK-6528430 - provide proper app name on Linux
try {
final Field awtAppClassName = xtoolkit.getDeclaredField("awtAppClassName"); //NOI18N
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i find it curious that the field isn't final -> we are lucky here since final might mean final in not too far future.

https://github.com/openjdk/jdk/blob/20c3082aac4381a5d38ed3abb34b3651b2d28e08/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java#L164

I think this is ok since it is only moving code around. But all those hacks have to go away. Every --add-opens flag we set is a red flag.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's such a commonly used workaround that it's probably deliberately kept like that. An API or system property would be great for this, but it doesn't look like it's happening anytime soon! https://bugs.openjdk.org/browse/JDK-6528430 😄 This will also need consideration if/when there's a move from XWayland to Wakefield.

The only other workaround is to ensure the toolkit is initialized from the main thread, but that would lead to a shared WM_CLASS across all platform applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Platform [ci] enable platform tests (platform/*)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants