Skip to content

wakefield: MainWindow WLToolkit CCE fix#9004

Merged
mbien merged 2 commits intoapache:masterfrom
mbien:fix-wltoolkit-cce
Nov 12, 2025
Merged

wakefield: MainWindow WLToolkit CCE fix#9004
mbien merged 2 commits intoapache:masterfrom
mbien:fix-wltoolkit-cce

Conversation

@mbien
Copy link
Member

@mbien mbien commented Nov 12, 2025

first commit is the fix, second is just cleanup

  • only run x11 workarounds when x11 toolkit is active
  • remove old GTK workaround which causes launch failure with wayland toolkit active
  • wakefield may use WLToolkit on wayland (-Dawt.toolkit.name=WLToolkit)

The #183739 might be still useful, unfortunately I don't know what #198639 does since bugzilla isn't loading the issue for me. edit: see #9004 (comment)

symptom: startup failure

Details
java.lang.ExceptionInInitializerError
	at java.desktop/sun.awt.X11.XAtom.<init>(XAtom.java:244)
	at java.desktop/sun.awt.X11.XWM.<clinit>(XWM.java:340)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at java.base/java.lang.Class.forName(Class.java:458)
	at org.netbeans.core.windows.view.ui.MainWindow.init(MainWindow.java:136)
	at org.netbeans.core.windows.WindowSystemImpl.init(WindowSystemImpl.java:46)
	at org.netbeans.core.GuiRunLevel.initializeMainWindow(GuiRunLevel.java:127)
	at org.netbeans.core.GuiRunLevel.run(GuiRunLevel.java:72)
	at org.netbeans.core.startup.Main.start(Main.java:316)
	at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:97)
	at java.base/java.lang.Thread.run(Thread.java:1474)
Caused by: java.lang.ClassCastException: class sun.awt.wl.WLGraphicsEnvironment cannot be cast to class sun.awt.X11GraphicsEnvironment (sun.awt.wl.WLGraphicsEnvironment and sun.awt.X11GraphicsEnvironment are in module java.desktop of loader 'bootstrap')
	at java.desktop/sun.awt.X11.XToolkit.<clinit>(XToolkit.java:508)
	... 12 more

I don't think project wakefield has made builds available yet, so to test this (linux+wayland) it would require the following:

git clone -b jdk25-wayland --single-branch --depth 5 https://github.com/openjdk/wakefield.git
cd wakefield && bash configure --with-vulkan && make images

start nb using the wakefield JDK with the following flags:

-J-Dawt.toolkit.name=WLToolkit -J-Dsun.java2d.vulkan=True

you should see something like this in the log instead of the exception:

Vulkan rendering enabled: YES
  Presentation enabled: YES
  Accelerated surface data enabled: YES
  Devices:
    *0: NVIDIA GeForce GTX 1080

Doesn't look great on my system though. Something is wrong with the font AA, popups are all over the place and some overlays (e.g editor highlighting layer) don't work. It runs at least.

thanks to @cstamas for noticing this.

@mbien mbien added this to the NB29 milestone Nov 12, 2025
@mbien mbien added Platform [ci] enable platform tests (platform/*) UI User Interface ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Nov 12, 2025
Copy link
Member

@neilcsmith-net neilcsmith-net left a comment

Choose a reason for hiding this comment

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

Thanks! Looks like what was suggested on Slack should we decide to keep this workaround in place.

NB. NetBeans can be run on the full JDK version of JBR to test this too, rather than requiring to build the JDK.

@mbien
Copy link
Member Author

mbien commented Nov 12, 2025

NB. NetBeans can be run on the full JDK version of JBR to test this too, rather than requiring to build the JDK.

yep the JBR SDK ships wakefield. I prefer the most direct approach to test things though. Building JDKs is super easy.

@mbien
Copy link
Member Author

mbien commented Nov 12, 2025

Looks like what was suggested on Slack should we decide to keep this workaround in place.

the first workaround makes sense to me and is mostly harmless. I can't access the second issue unfortunately so I don't know if it makes sense to keep it. But its probably ok to stay as long X11 still exists, removing --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED would switch it off too.

edit: archive.org to the rescue! lets take another look

@mbien
Copy link
Member Author

mbien commented Nov 12, 2025

regarding #198639 / archive (the second workaround which was also the cause of the startup error).

I believe the better option there is to remove the workaround entirely. It could cause side effects and it appears that it was implemented for GTK LAF + old gnome version + X11 specifically, without checking if it is even active. E.g users reported that switching to metal fixed it - which should also apply to FlatLAF.

The more encapsulation breaking hacks we get rid off the better. Will update the PR.

remove old GTK workaround which causes launch failure with wayland
toolkit active (-Dawt.toolkit.name=WLToolkit)

old bugzilla issue ID: 198639
language level and IDE warning fixes
@mbien mbien force-pushed the fix-wltoolkit-cce branch from fec6bba to 496f09a Compare November 12, 2025 18:41
@cstamas
Copy link
Member

cstamas commented Nov 12, 2025

@mbien followed your great instructions, but did not build this PR but ran "vanilla" 27 and it works nicely. What you see "popups are all over the place and some overlays" etc may be the fact that I have AMD and you NVidia? For me it just works.

Product Version: Apache NetBeans IDE 27
Java: 25-internal; OpenJDK 64-Bit Server VM 25-internal-adhoc.cstamas.wakefield
Runtime: OpenJDK Runtime Environment 25-internal-adhoc.cstamas.wakefield
System: Linux version 6.17.7-300.fc43.x86_64 running on amd64; UTF-8; en_US (nb)
User directory: /home/cstamas/.netbeans/27
Cache directory: /home/cstamas/.cache/netbeans/27

Started with NB27 "trick" as @neilcsmith-net pointed out to me:

[cstamas@angeleyes netbeans]$ # edit etc/netbeans.conf to point at built wakefield
[cstamas@angeleyes netbeans]$ DESKTOP_SESSION= ./bin/netbeans -J-Dawt.toolkit.name=WLToolkit -J-Dsun.java2d.vulkan=True
Detected 2x HiDPI scaling in Xft.dpi setting; setting GDK_SCALE=2
WARNING: package com.apple.eio not in java.desktop
WARNING: package com.sun.tools.classfile not in jdk.jdeps
WARNING: package com.sun.java.swing.plaf.windows not in java.desktop
WARNING: package com.apple.laf not in java.desktop
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (jar:file:/home/cstamas/Tools/netbeans/27/netbeans/java/maven/lib/guice-5.1.0-classes.jar!/)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
[cstamas@angeleyes netbeans]$ 

@mbien
Copy link
Member Author

mbien commented Nov 12, 2025

@cstamas thanks for testing! Yeah my system isn't a good indicator since I am still using cinnamon where wayland support is still considered experimental. I do actually like how simple and stable the window manager is, but if this doesn't improve with the upcoming releases I will switch to something else at some point.

@mbien mbien merged commit a6f1478 into apache:master Nov 12, 2025
61 of 62 checks passed
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/*) UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants