异常堆栈信息
java.lang.NullPointerException: null
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
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:379)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:324)
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
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.newInstance(Constructor.java:490)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/java.awt.Font.getFont2D(Font.java:497)
at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:237)
at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:158)
at java.desktop/sun.java2d.SunGraphics2D.checkFontInfo(SunGraphics2D.java:670)
at java.desktop/sun.java2d.SunGraphics2D.getFontInfo(SunGraphics2D.java:836)
at java.desktop/sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:46)
at java.desktop/sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:165)
at java.desktop/sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2934)
。。。省略其它业务代码
11.0.16.1 linux 平台对应源码\java.desktop\sun\awt\FontConfiguration.java。 getVersion() 是private 且不依赖外部参数
private void readFontConfigFile(File f) {
/* This is invoked here as readFontConfigFile is only invoked
* once per VM, and always in a privileged context, thus the
* directory containing installed fall back fonts is accessed
* from this context
*/
getInstalledFallbackFonts(javaLib);
if (f != null) {
try {
FileInputStream in = new FileInputStream(f.getPath());
if (isProperties) {
loadProperties(in);
} else {
loadBinary(in);
}
in.close();
if (FontUtilities.debugFonts()) {
logger.config("Read logical font configuration from " + f);
}
} catch (IOException e) {
if (FontUtilities.debugFonts()) {
logger.config("Failed to read logical font configuration from " + f);
}
}
}
String version = getVersion();
if (!"1".equals(version) && FontUtilities.debugFonts()) {
logger.config("Unsupported fontconfig version: " + version);
}
}
解决: 小版本升级至11.0.20或以上即可