Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8304054

Linux: NullPointerException from FontConfiguration.getVersion in case no fonts are installed

    XMLWordPrintable

Details

    • b19
    • generic
    • linux

    Backports

      Description

        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.

        Attachments

          Issue Links

            Activity

              People

                mbaesken Matthias Baesken
                mbaesken Matthias Baesken
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: