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

Adding null child leads to exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
      None

      Description

      A few times I have accidentally added a null child to a parent. This does not result in an immediate error, rather, at some later point in time I get the NPE and an Assertion error as seen below:

      java.lang.NullPointerException
      at javafx.scene.Parent.computePrefHeight(Parent.java:872)
      at javafx.scene.layout.Region.computePrefHeight(Region.java:1460)
      at javafx.scene.Parent.prefHeight(Parent.java:823)
      at javafx.scene.layout.Region.prefHeight(Region.java:1368)
      at javafx.scene.layout.Region.computeChildPrefAreaHeight(Region.java:1594)
      at javafx.scene.layout.Region.getMaxAreaHeight(Region.java:1716)
      at javafx.scene.layout.Region.computeMaxPrefAreaHeight(Region.java:1688)
      at javafx.scene.layout.StackPane.computePrefHeight(StackPane.java:300)
      at javafx.scene.Parent.prefHeight(Parent.java:823)
      at javafx.scene.layout.Region.prefHeight(Region.java:1368)
      at javafx.scene.layout.Region.computeChildPrefAreaHeight(Region.java:1594)
      at javafx.scene.layout.VBox.getAreaHeights(VBox.java:376)
      at javafx.scene.layout.VBox.computePrefHeight(VBox.java:355)
      at javafx.scene.Parent.prefHeight(Parent.java:823)
      at javafx.scene.layout.Region.prefHeight(Region.java:1368)
      at javafx.scene.Parent.computePrefHeight(Parent.java:875)
      at javafx.scene.layout.Region.computePrefHeight(Region.java:1460)
      at javafx.scene.Parent.prefHeight(Parent.java:823)
      at javafx.scene.layout.Region.prefHeight(Region.java:1368)
      at javafx.scene.Node.autosize(Node.java:2319)
      at javafx.scene.Parent.impl_resizeChildren(Parent.java:947)
      at javafx.scene.layout.Region.layoutChildren(Region.java:1500)
      at javafx.scene.Parent.layout(Parent.java:910)
      at javafx.scene.Parent.layout(Parent.java:920)
      at javafx.scene.Parent.layout(Parent.java:920)
      at javafx.scene.Scene.layoutDirtyRoots(Scene.java:474)
      at javafx.scene.Scene.doLayoutPass(Scene.java:447)
      at javafx.scene.Scene.access$3000(Scene.java:133)
      at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:1851)
      at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:290)
      at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:393)
      at com.sun.javafx.tk.quantum.QuantumToolkit$8.run(QuantumToolkit.java:319)

      As you can see from the stack trace, only JavaFX classes are involved, so my code indirectly makes JavaFX crash, but JavaFX does very little to provide useful debugging information. I recommend improving this to provide fail fast behavior or at least a more informative exception.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              lnerad Ľubomír Nerád
              Reporter:
              risaksen Randahl Isaksen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: