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

NPE when JavaFX loads default stylesheet or font families if CCL is null

    XMLWordPrintable

Details

    Backports

      Description

        JavaFX captures the Context Class Loader (CCL) of the calling thread at the time the JavaFX toolkit is initialized, and uses that as the CCL of the JavaFX Application Thread. We then use the CCL to locate user resources, and require it to be non-null in order for those resources to be located. Among these are CSS, FXML, Media, and Image if URIs without a protocol are used.

        Starting in JDK 8, JavaFX also references the CCL when loading its own resources, such as loading the default style sheet and looking for embedded fonts, and does so in a way that causes those operations to abort with an NPE when the null CCL is referenced.

        The two attached simple test programs illustrate this:

        1. NullCCLControlTest -- constructs a Label (any UI control will fail similarly), which will load the default "modena.css" stylesheet

        2. NullCCLHTMLEditorTest -- constructs and displays an HTMLEditor, which will load the default "modena.css" stylesheet, and then get a list of all font families.

        In JDK 8, both test programs fail with an NPE and display nothing.

        In JDK 9, the loading of the CSS resources has been fixed (as part of a larger bug fix for Jigsaw), so creating a Label or other UI control is able to load the stylesheet, but getting the list of font families still fails. So on JDK 9, test program #1 works, while test #2 fails with an NPE when the HTMLEditor tries to popuplate the list of fonts.

        -------------------------------------
        Original description is below
        -------------------------------------

        java.lang.ExceptionInInitializerError -
        com.sun.javafx.webkit.theme.ScrollBarThemeImpl$1.invalidated(ScrollBarThemeImp
        l.java:109)
        ...
        Caused by: java.lang.NullPointerException
         at com.sun.javafx.css.StyleManager.getURL(StyleManager.java:860)

        The exception stack trace is same as in JDK-8093938

        Attachments

          Issue Links

            Activity

              People

                kcr Kevin Rushforth
                shadowbug Shadow Bug
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: