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. 

0

It gets to BasicLabelUI.java::getPreferredSize() where `Font font = label.getFont()` returns:

Method threw 'java.lang.InternalError' exception. Cannot evaluate javax.swing.plaf.FontUIResource.toString()

and that uncaught exception means `font` is now not null to get caught by the proceeding `if...font == null` conditionals

0

Please use JDK 11 to run the IDE.

0

Morning, switching to JDK 11 alters the error message slightly,

SettingsWindowTests > logVerbosityTestAbNormal() FAILED
java.lang.UnsatisfiedLinkError: no freetype in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
at java.base/java.lang.System.loadLibrary(System.java:1867)
at java.desktop/sun.font.FontManagerNativeLibrary$1.run(FontManagerNativeLibrary.java:55)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerNativeLibrary.<clinit>(FontManagerNativeLibrary.java:32)
at java.desktop/sun.font.SunFontManager$1.run(SunFontManager.java:270)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<clinit>(SunFontManager.java:266)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:265)
at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1231)
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.<init>(SettingsWindowTests.java:10)

However I'm unsure how the tests can pass every-other time, if there is actually a missing library.

 

0

What is the exact JDK you're using now? Are you using JetBrains Runtime?

0
./gradlew --version

------------------------------------------------------------
Gradle 6.4.1
------------------------------------------------------------

Build time: 2020-05-15 19:43:40 UTC
Revision: 1a04183c502614b5c80e33d603074e0b4a2777c5

Kotlin: 1.3.71
Groovy: 2.5.10
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
OS: Linux 4.15.0-142-generic amd64

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.

0

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 

0

I've just tried with JDK 16, and on brand new Ubuntu 20 machine and the problem remains

0

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.

0

请先登录再写评论。