bulenkov / Darcula

Darcula Look and Feel
Apache License 2.0
723 stars 114 forks source link

Not working with Java 9 #23

Open davidekholm opened 7 years ago

davidekholm commented 7 years ago

When trying to use Darcula on Java 9, I get the following exception:

java.lang.IllegalAccessError: class com.bulenkov.darcula.DarculaLaf (in unnamed module @0x62e7f11d) cannot access class sun.awt.AppContext (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @0x62e7f11d at com.bulenkov.darcula.DarculaLaf.patchStyledEditorKit(DarculaLaf.java:128) at com.bulenkov.darcula.DarculaLaf.getDefaults(DarculaLaf.java:93) at javax.swing.UIManager.setLookAndFeel(java.desktop@9-ea/UIManager.java:584) at javax.swing.UIManager.setLookAndFeel(java.desktop@9-ea/UIManager.java:628) at se.datadosen.jalbum.JAlbum.main(JAlbum.java:332) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method) at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62) at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:537) at se.datadosen.jalbum.Main.main(Main.java:44)

davidekholm commented 7 years ago

Any plans for addressing Java 9 compatibility? We'd like to make Darcula the default look and feel for jAlbum but we're hesitating as it still won't run on Java 9. Java 9 fixed a serious rendering issue for 4K screens so we need to move to Java 9 as soon as it is released in July -17.

bulenkov commented 7 years ago

Please try to run. Also, I would recommend you to use JetBrains Runtime to run your app. JetBrains Runtime is a fork of OpenJDK containing patches for HiDPI support, subpixel font rendering, and other subsystems. It's used by 3M+ software developers for running IntelliJ IDEA and other JetBrains' tools. Also, it's used by Google for Android Studio with millions of users too. My recommendation is to bundle JRE into your app and don't think about user environment at all. Number of issues fixed in Java 9 made by JetBrains Runtime team and a big number of features (like emodji support) is not a part of Java 9. Take a look if you're interested https://bintray.com/jetbrains/intellij-jdk/

dpatriarche commented 7 years ago

How does one enabled HiDPI support in a Swing app running on the IntelliJ-JRE? Some Googling suggested VM option -Dhidpi-true might work, but it doesn't seem to.

davidekholm commented 7 years ago

Thanks for responding to this. I tested the update on Java 9. That error seems to be gone, but now it crashes on references to SwingUtilities2. I know you're using SwingUtilities2 to calculate the location for underlining characters bound to ALT+keyboard shortcuts, but SwingUtilities is now a closed API, so I suggest to simply copy that method to your own code cause I'm not aware of any official replacement for SwingUtilities2:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: class com.bulenkov.darcula.ui.DarculaButtonUI (in unnamed module @0x2d7275fc) cannot access class sun.swing.SwingUtilities2 (in module java.desktop) because module java.desktop does not export sun.swing to unnamed module @0x2d7275fc at com.bulenkov.darcula.ui.DarculaButtonUI.paintText(DarculaButtonUI.java:79) at java.desktop/javax.swing.plaf.basic.BasicButtonUI.paintText(Unknown Source) at java.desktop/javax.swing.plaf.basic.BasicButtonUI.paint(Unknown Source) at com.bulenkov.darcula.ui.DarculaButtonUI.paint(DarculaButtonUI.java:64) at java.desktop/javax.swing.plaf.ComponentUI.update(Unknown Source) at com.bulenkov.darcula.ui.DarculaButtonUI.update(DarculaButtonUI.java:103) at java.desktop/javax.swing.JComponent.paintComponent(Unknown Source) at se.datadosen.component.JToolBarButton.paintComponent(JToolBarButton.java:147) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/javax.swing.JLayeredPane.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source) at java.desktop/javax.swing.JComponent.paintToOffscreen(Unknown Source) at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(Unknown Source) at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) at java.desktop/javax.swing.RepaintManager$PaintManager.paint(Unknown Source) at java.desktop/javax.swing.RepaintManager.paint(Unknown Source) at java.desktop/javax.swing.JComponent.paint(Unknown Source) at java.desktop/java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) at java.desktop/sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) at java.desktop/sun.awt.SunGraphicsCallback.runComponents(Unknown Source) at java.desktop/java.awt.Container.paint(Unknown Source) at java.desktop/java.awt.Window.paint(Unknown Source) at java.desktop/javax.swing.RepaintManager$4.run(Unknown Source) at java.desktop/javax.swing.RepaintManager$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source) at java.desktop/javax.swing.RepaintManager.access$1200(Unknown Source) at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue.access$500(Unknown Source) at java.desktop/java.awt.EventQueue$3.run(Unknown Source) at java.desktop/java.awt.EventQueue$3.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

davidekholm commented 7 years ago

I will look into JetBrain's JDK branch too. Wasn't aware of it really. Exciting. Still, I feel it's important that Darcula is secured for Java 9 so I hope you can address the remaining incompatibility issues.

davidekholm commented 7 years ago

Do you think you can fix this (hopefully) last remaining Java 9 issue? I would feel far more comfortable making Darcula the default look and feel knowing this has been addressed so we don't have to move away from Darcula when eventually moving to Java 9.

pmouawad commented 6 years ago

Did you try adding: --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.swing=ALL-UNNAMED

davidekholm commented 6 years ago

Yes, and those work from the command line, but can't be passed to the JVM via the installer wrapper's launcher file. (I've brought that up with the makers of AdvancedInstaller though). If users simply double click jAlbum's jar file, those flags won't be passed either, so it's not a good long term solution.

I understand the problem from your point of view. You've been relying to some degree on now unofficial utility classes and Oracle haven't provided official alternatives for all of these. Can I ask you to bring this up with Oracle?

Regards /David

On 30 Oct 2017, at 18:58, Philippe M notifications@github.com wrote:

Did you try adding: --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.swing=ALL-UNNAMED

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bulenkov/Darcula/issues/23#issuecomment-340531015, or mute the thread https://github.com/notifications/unsubscribe-auth/ACJ9SCu69ZQV6KCoVOVlShVcToxWqAMhks5sxg5HgaJpZM4KqN8L.

kirill-grouchnikov commented 6 years ago

SwingUtilities2.getFontMetrics(c, g) -> c.getFontMetrics(g.getFont()) SwingUtilities2.drawStringUnderlineCharAt -> BasicGraphicsUtils.drawStringUnderlineCharAt

JJBRT commented 2 years ago

It can be solved without any JVM parameter with Burningwave Core reflection components that thanks to a special driver work on all JDKs from 8. In this case you can also simply call the method org.burningwave.core.assembler.StaticComponentContainer.Modules.exportAllToAll()

apenczolgolonabijorbiper commented 1 year ago

solution that worked for me: in jmeter.bat for the line with set JAVA9_OPTS=--add-opens... I added at the end the following parameter: --add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED

davidekholm commented 1 year ago

Hi. Thanks. I know that's a working workaround, but prefer to avoid special flags. We've actually moved to using FlatLaf. It's free and looks at least as good as Darcula. It even has a Darcula theme.