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

[Dialogs] ChoiceDialog default constructor throws NullPointerException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:
      None
    • Environment:

      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)

      Description

      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<>();
          }
      }

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported: