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

Java 16 Crash "no ComponentUI class ..." #8

Open
tresf opened this issue Jun 10, 2021 · 1 comment
Open

Java 16 Crash "no ComponentUI class ..." #8

tresf opened this issue Jun 10, 2021 · 1 comment

Comments

@tresf
Copy link

tresf commented Jun 10, 2021

Starting with Java 16 (in this case, on MacOS 11 however others may be affected), this library throws the following error:

java.lang.Error: no ComponentUI class for: javax.swing.JOptionPane[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,icon=,initialValue=,message=test,messageType=INFORMATION_MESSAGE,optionType=DEFAULT_OPTION,wantsInput=false]
	at java.desktop/javax.swing.UIDefaults.getUIError(UIDefaults.java:762)
	at java.desktop/javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:144)
	at java.desktop/javax.swing.UIDefaults.getUI(UIDefaults.java:792)
	at java.desktop/javax.swing.UIManager.getUI(UIManager.java:1069)
	at java.desktop/javax.swing.JOptionPane.updateUI(JOptionPane.java:1873)
	at java.desktop/javax.swing.JOptionPane.<init>(JOptionPane.java:1838)
	at java.desktop/javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:862)
	at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:670)
	at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:641)
	at java.desktop/javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:612)
	at qz.Test.lambda$main$0(Test.java:9)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:306)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

This error may vary but it is reproducible with the following JDKs:

  • Zulu 16
  • AdoptOpenJDK 16
  • Homebrew's OpenJDK 16

Code to reproduce:

public static void main(String ... args) throws Throwable {
   UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf");
   SwingUtilities.invokeAndWait(() -> {
      JOptionPane.showMessageDialog(null, "test");
   });
}

Commenting out the line UIManager.setLookAndFeel will prevent the crash.

@tresf
Copy link
Author

tresf commented Jun 14, 2021

A workaround, add the following JVM property:

--add-exports java.desktop/sun.swing=ALL-UNNAMED

... and if on macOS, also add:

--add-exports java.desktop/com.apple.laf=ALL-UNNAMED

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

1 participant