Plugin Unit Test failing with sun.font.FontManagerFactory error on Ubuntu 16 with JDK 14/15
已回答
I'm seeing an error when running `./gradlew test` to run my plugin's settings menu's unit tests. Specifically it is failing when trying to create a Hashtable with the line:
Hashtable<Integer, JLabel> table = newHashtable<>();
And each test fails with this log:
SettingsWindowTests > logVerbosityTestAbNormal() FAILED
java.lang.InternalError: java.lang.reflect.InvocationTargetException
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/sun.font.SunFontManager.getInstance(SunFontManager.java:249)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:261)
at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1243)
at java.desktop/javax.swing.JComponent.getFontMetrics(JComponent.java:1646)
at java.desktop/javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:246)
at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
at java.desktop/javax.swing.JSlider.updateLabelUIs(JSlider.java:853)
at java.desktop/javax.swing.JSlider.setLabelTable(JSlider.java:824)
at java.desktop/javax.swing.JSlider.setPaintLabels(JSlider.java:1315)
at com.company.asplugin.settings.SettingsWindow.$$$setupUI$$$(SettingsWindow.java)
at com.company.asplugin.settings.SettingsWindow.<init>(SettingsWindow.java:70)
at com.company.asplugin.settings.SettingsWindowTests.configSetup(SettingsWindowTests.java:14)
Caused by:
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
... 14 more
Caused by:
java.lang.NullPointerException
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:374)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:319)
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
... 20 more
I have tried with JDK14 JDK15 and adoptJDK14+12. The plugin uses Intellij.version '2019.1.3', and I have updated to version '2021.1.2' but the problem remains.
If I run the Unit Tests from within IDEA, they only fail 50% of the time, from the command line it is every time.
请先登录再写评论。
It gets to BasicLabelUI.java::getPreferredSize() where `Font font = label.getFont()` returns:
and that uncaught exception means `font` is now not null to get caught by the proceeding `if...font == null` conditionals
Please use JDK 11 to run the IDE.
Morning, switching to JDK 11 alters the error message slightly,
However I'm unsure how the tests can pass every-other time, if there is actually a missing library.
What is the exact JDK you're using now? Are you using JetBrains Runtime?
It's my understanding that the runtime is part of the build.gradle line `intellij.version` which I use 2019.1.3, but I also tried with 2021.1.2 and it was the same error.
I only switched to 11 as you've asked. I have build machines for Windows, Mac, and Ubuntu 20 which don't have this issue if that helps narrow things down
I've just tried with JDK 16, and on brand new Ubuntu 20 machine and the problem remains
Please verify the runtime used in the (debug instance of) IDE itself. See "About" dialog or entry in idea.log upon start (Help->Show Log). Pleae also make sure you're using the latest version of gradle-intellij-plugin.