JDK-8193062 : Unable to launch JavaFX application if an invalid font is installed
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 8u121
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • Submitted: 2017-12-05
  • Updated: 2017-12-07
  • Resolved: 2017-12-07
Related Reports
Duplicate :  
Description
If an invalid font file is installed no javafx application can be launched un such a system because application startup fails with an NPE.

 Caused by: java.lang.NullPointerException

at com.sun.javafx.font.MacFontFinder.populateFontFileNameMap(MacFontFinder.java:99)

at com.sun.javafx.font.PrismFontFactory.getFullNameToFileMap(PrismFontFactory.java:1740)

at com.sun.javafx.font.PrismFontFactory.getFontResource(PrismFontFactory.java:469)

at com.sun.javafx.font.LogicalFont.getSlot0Resource(LogicalFont.java:194)

at com.sun.javafx.font.LogicalFont.getDefaultAAMode(LogicalFont.java:409)

at com.sun.javafx.font.LogicalFont.getStrike(LogicalFont.java:413)

at com.sun.javafx.font.PrismFont.getStrike(PrismFont.java:73)

at com.sun.javafx.text.PrismTextLayout.setContent(PrismTextLayout.java:138)

at javafx.scene.text.Text.getTextLayout(Text.java:229)

at javafx.scene.text.Text.needsFullTextLayout(Text.java:184)

at javafx.scene.text.Text.access$200(Text.java:95)

at javafx.scene.text.Text$5.invalidated(Text.java:501)

at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)

at javafx.beans.property.ObjectPropertyBase.bind(ObjectPropertyBase.java:174)

at javafx.css.StyleableObjectProperty.bind(StyleableObjectProperty.java:75)

at com.sun.javafx.scene.control.skin.LabeledText.<init>(LabeledText.java:82)

at com.sun.javafx.scene.control.skin.LabeledSkinBase.<init>(LabeledSkinBase.java:125)

at com.sun.javafx.scene.control.skin.LabelSkin.<init>(LabelSkin.java:39)

at javafx.scene.control.Label.createDefaultSkin(Label.java:158)

at javafx.scene.control.Control.impl_processCSS(Control.java:872)

at javafx.scene.Parent.impl_processCSS(Parent.java:1280)

at javafx.scene.Parent.impl_processCSS(Parent.java:1280)

at javafx.scene.Parent.impl_processCSS(Parent.java:1280)

at javafx.scene.Parent.impl_processCSS(Parent.java:1280)

at javafx.scene.control.PopupControl$CSSBridge.impl_processCSS(PopupControl.java:1181)

at javafx.scene.Parent.impl_processCSS(Parent.java:1280)

at javafx.scene.Node.processCSS(Node.java:9058)

at javafx.scene.Node.applyCss(Node.java:9155)

at javafx.scene.control.PopupControl.recomputeSkinSize(PopupControl.java:965)

at javafx.scene.control.PopupControl.recalculateMinWidth(PopupControl.java:935)

at javafx.scene.control.PopupControl.minWidth(PopupControl.java:820)

at com.sun.javafx.scene.control.skin.ChoiceBoxSkin.computeMinWidth(ChoiceBoxSkin.java:331)

at javafx.scene.control.Control.computeMinWidth(Control.java:470)

at javafx.scene.Parent.minWidth(Parent.java:943)

at javafx.scene.layout.Region.minWidth(Region.java:1383)

at javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1667)

at javafx.scene.layout.HBox.getAreaWidths(HBox.java:455)

at javafx.scene.layout.HBox.computeContentWidth(HBox.java:532)

at javafx.scene.layout.HBox.computeMinWidth(HBox.java:402)

at javafx.scene.Parent.minWidth(Parent.java:943)

at javafx.scene.layout.Region.minWidth(Region.java:1383)

at javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1667)

at javafx.scene.layout.BorderPane.getAreaWidth(BorderPane.java:609)

at javafx.scene.layout.BorderPane.computeMinWidth(BorderPane.java:368)

at javafx.scene.Parent.minWidth(Parent.java:943)

at javafx.scene.layout.Region.minWidth(Region.java:1383)

at javafx.scene.layout.BorderPane.layoutChildren(BorderPane.java:484)

at javafx.scene.Parent.layout(Parent.java:1087)

at javafx.scene.Scene.doLayoutPass(Scene.java:552)

at javafx.scene.Scene.preferredSize(Scene.java:1646)

at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)

at javafx.stage.Window$9.invalidated(Window.java:846)

at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)

at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)

at javafx.stage.Window.setShowing(Window.java:922)

at javafx.stage.Window.show(Window.java:937)

at javafx.stage.Stage.show(Stage.java:259)

This a severe bug because NO JavaFX applications can start on such a system!
Comments
This sounds like the same issue as these two reports : https://bugs.openjdk.java.net/browse/JDK-8089900 https://bugs.openjdk.java.net/browse/JDK-8154845 I don't think we have a root cause and the font being referenced in this bug is one of the Mac system fonts .. so it should not be invalid. I suggest trying the same workaround as in those bugs -> It is always resolved by restoring stand fonts in Font Book (File->Restore Standard Fonts). the native method getFontData is not returning a null array but the elements are all null as if thecoretext calls in addCTFontDescriptor in the file MacFontFinder.c failed to return at least one of name, family or file for the resource. The code has logic that leaves all of them as NULL if any are NULL. So in this case the calling code (where we NPE) ought to be ready for this Probably what we should do - even if we don't know why it happens - is to put null checks in the Java code. And I expect it will affect 9 & 10 since neither the Java or native code here has changed at all in over 3 years ..
05-12-2017

does it affect 9? 10?
05-12-2017

running with -Dprism.debugfonts=true i get on this system ..... Family=.SF NS Text File=/System/Library/Fonts/SFNSText.ttf [MacFontFinder] Name=System Font Bold Family=.SF NS Text File=/System/Library/Fonts/SFNSText.ttf [MacFontFinder] Name=null Family=null File=null
05-12-2017