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

FXMLLoader fails to load a sub layout using fx:include with the resources attribute

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Using OpenJFX 15 on AdoptOpenJDK 15

      A DESCRIPTION OF THE PROBLEM :
      FXMLLoader fails to load a sub layout using `fx:include` with the `resources` attribute.

      parent.fxml:

      <?import javafx.scene.layout.AnchorPane?>
      <AnchorPane xmlns:fx="http://javafx.com/fxml">
          <children>
              <fx:include source="child.fxml" resources="home.properties"/>
          </children>
      </AnchorPane>

      child.fxml (empty pane):

      <?import javafx.scene.layout.AnchorPane?>
      <AnchorPane xmlns:fx="http://javafx.com/fxml">
      </AnchorPane>

      Generates the following error at runtime:

      Exception in Application start method
      ...
      Caused by: java.lang.NullPointerException
      at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:1281)
      at javafx.fxml/javafx.fxml.FXMLLoader$IncludeElement.processAttribute(FXMLLoader.java:1103)
      at javafx.fxml/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:229)
      at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:754)
      at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
      at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
      ... 16 more

      After inspecting FXMLLoader.java and ResourceBundle.java at those lines it's apparent FXMLLoader needs to call a different overload of getBundle when .getClassLoader() is null (happens if the parent class was loaded by the bootstrap loader). I'll submit a PR on GitHub for this.


      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            kcr Kevin Rushforth
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: