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

[Dialogs] ChoiceDialog default constructor throws NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u40
    • 8u40
    • javafx
    • None
    • U:\>java -version
      java version "1.8.0_40-ea"
      Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 25.40-b10, mixed mode)

      The default constructor for ChoiceDialog throws a NullPointerException

      Caused by: java.lang.NullPointerException
      at java.util.Objects.requireNonNull(Objects.java:203)
      at java.util.Arrays$ArrayList.<init>(Arrays.java:3813)
      at java.util.Arrays.asList(Arrays.java:3800)
      at javafx.scene.control.ChoiceDialog.<init>(ChoiceDialog.java:95)
      at javafx.scene.control.ChoiceDialog.<init>(ChoiceDialog.java:78)

      Also the Javadocs for this constructor mentions the getItems() method but I think the setItems() method was intended.

      Here is a short program to trigger the NPE.

      import javafx.application.Application;
      import javafx.scene.control.ChoiceDialog;
      import javafx.stage.Stage;

      public class DialogTest2 extends Application {

          public static void main(String[] args) {
              launch(args);
          }
       
          @Override
          public void start(Stage stage) {
      ChoiceDialog<String> choiceDialog = new ChoiceDialog<>();
          }
      }

            jgiles Jonathan Giles
            dgilbertjfx David Gilbert (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: