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

FXMLLoader throws NPE when parsing some binding expression in static mode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8u20
    • None
    • javafx

    Description

      When FXMLLoader is invoked :
      - on the attached file (DataSetUIv2.fxml)
      - with FXMLLoader.impl_setStaticLoad(true)

      it raises the NPE described below.
      If the static load is disabled, then NPE does not appear.
      So it seems that expression evaluation is not dealing correctly with static load.


      Here is the NPE stack:

      unknown path:137

      at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2593)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2571)
      at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2417)
      at Oxebo.start(Oxebo.java:34)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$137(LauncherImpl.java:821)
      at com.sun.javafx.application.LauncherImpl$$Lambda$51/105503094.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$149(PlatformImpl.java:319)
      at com.sun.javafx.application.PlatformImpl$$Lambda$45/1851691492.run(Unknown Source)
      at com.sun.javafx.application.PlatformImpl.lambda$null$147(PlatformImpl.java:288)
      at com.sun.javafx.application.PlatformImpl$$Lambda$47/1567428247.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$148(PlatformImpl.java:287)
      at com.sun.javafx.application.PlatformImpl$$Lambda$46/815033865.run(Unknown Source)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      Caused by: java.lang.NullPointerException
      at com.sun.javafx.fxml.expression.Expression.lambda$not$14(Expression.java:1476)
      at com.sun.javafx.fxml.expression.Expression$$Lambda$101/1109741740.apply(Unknown Source)
      at com.sun.javafx.fxml.expression.UnaryExpression.evaluate(UnaryExpression.java:49)
      at com.sun.javafx.fxml.expression.ExpressionValue.getValue(ExpressionValue.java:192)
      at com.sun.javafx.binding.ExpressionHelper.addListener(ExpressionHelper.java:54)
      at javafx.beans.value.ObservableValueBase.addListener(ObservableValueBase.java:55)
      at com.sun.javafx.fxml.expression.ExpressionValue.addListener(ExpressionValue.java:201)
      at javafx.beans.binding.BooleanBinding.bind(BooleanBinding.java:107)
      at javafx.beans.property.BooleanPropertyBase$1.<init>(BooleanPropertyBase.java:167)
      at javafx.beans.property.BooleanPropertyBase.bind(BooleanPropertyBase.java:164)
      at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:314)
      at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:231)
      at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:761)
      at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2815)
      at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2524)
      ... 12 more



      Here is a sample java class which exhibits the loading issue:

      import java.io.IOException;
      import java.io.InputStream;
      import java.net.URL;

      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.stage.Stage;


      public class Oxebo extends Application {

      public static void main(String[] args) {
      Application.launch(args);
      }

      /*
      * Application
      */

      @Override
      public void start(Stage primaryStage) throws Exception {
      Object root;
      final URL fxmlURL = getClass().getResource("DataSetUiV2.fxml");
      assert fxmlURL != null;
      try (InputStream is = fxmlURL.openConnection().getInputStream()) {
      FXMLLoader fxmlLoader = new FXMLLoader();
      fxmlLoader.impl_setStaticLoad(true); // NOTE : static load
      root = fxmlLoader.load(is);
      assert root instanceof Parent;
      } catch(IOException x) {
      x.printStackTrace();
      root = new Label("Load error");
      }

      primaryStage.setScene(new Scene((Parent)root));
      primaryStage.sizeToScene();
      primaryStage.show();
      }

      }

      Attachments

        Issue Links

          Activity

            People

              msladecek Martin Sládeček
              eleponn Eric Le Ponner
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: