Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Java 9 #23

Open
davidekholm opened this issue Nov 5, 2016 · 12 comments
Open

Not working with Java 9 #23

davidekholm opened this issue Nov 5, 2016 · 12 comments

Comments

@davidekholm
Copy link

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
Copy link
Author

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 added a commit that referenced this issue Feb 17, 2017
bulenkov added a commit that referenced this issue Feb 17, 2017
@bulenkov
Copy link
Owner

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
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link

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

@davidekholm
Copy link
Author

davidekholm commented Oct 30, 2017 via email

@kirill-grouchnikov
Copy link

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

@JJBRT
Copy link

JJBRT commented Sep 16, 2021

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

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants