RFR: JDK-8304054: Linux: NullPointerException from FontConfiguration.getVersion in case no fonts are installed [v2]

Matthias Baesken mbaesken at openjdk.org
Fri Apr 14 07:35:28 UTC 2023


> On Linux Alpine we were running in the jtreg awt tests into a lot of NPEs like this :
> 
> java.lang.InternalError: java.lang.reflect.InvocationTargetException
> at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
> at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
> at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
> at java.desktop/java.awt.Font.getFont2D(Font.java:526)
> at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:265)
> at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:148)
> at java.desktop/sun.font.GlyphLayout$SDCache.<init>(GlyphLayout.java:254)
> at java.desktop/sun.font.GlyphLayout$SDCache.get(GlyphLayout.java:328)
> at java.desktop/sun.font.GlyphLayout.layout(GlyphLayout.java:375)
> at java.desktop/java.awt.Font.layoutGlyphVector(Font.java:2858)
> at FontLayoutStressTest.doLayout(FontLayoutStressTest.java:51)
> at FontLayoutStressTest.main(FontLayoutStressTest.java:57)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
> at java.base/java.lang.Thread.run(Thread.java:833)
> 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:77)
> at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
> at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
> at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
> ... 17 more
> Caused by: java.lang.NullPointerException: Cannot load from short array because "sun.awt.FontConfiguration.head" is null
> at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
> at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224)
> at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:106)
> at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706)
> at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:358)
> at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:315)
> at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
> at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:315)
> at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
> at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
> ... 23 more
> 
> Seems this was caused because no fonts were installed on the machine.
> Probably 'head' in FontConfiguration.getVersion() should be checked for null and a specific exception like "Check your fonts or fonts configuration"
> should be throw.

Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:

  Avoid message duplication

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/13045/files
  - new: https://git.openjdk.org/jdk/pull/13045/files/e9e7b54b..24a30c18

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=13045&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13045&range=00-01

  Stats: 4 lines in 1 file changed: 2 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/13045.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13045/head:pull/13045

PR: https://git.openjdk.org/jdk/pull/13045



More information about the client-libs-dev mailing list