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

JavaFX crash when closing with the escape key

XMLWordPrintable

    • b24
    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      Linux Mint 21.1 Cinnamon with and without virtual machine (VMware® Workstation 16 Player 16.2.4 build-20089737)
      Java: Oracle Corporation(19.0.1)
      JavaFX version: 19+11

      A DESCRIPTION OF THE PROBLEM :
      The program crashes when some actions are performed in setOnKeyPressed triggered by pressing the escape key after closing the window.
      I don't understand why the call to create an xml document causes the bug.
      This bug seems to be well known (JDK-8272617, JDK-8087368, JDK-8095159, JDK-8140505, JDK-8189719, JDK-8143312, JDK-8095472, JDK-8170081, JDK-8193517), but I can reproduce it even in much simpler cases like the one in the source code example and on several computers.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the program and press the escape key.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The program should stop without crash.
      ACTUAL -
      The program generates a fatal error.

      ---------- BEGIN SOURCE ----------
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.ParserConfigurationException;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.TextField;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class FatalCrash extends Application {

      public static void main(String[] args) {
              System.out.println("Java: " + System.getProperty("java.vendor") + "(" + System.getProperty("java.version") + ")");
              System.out.println("JavaFX version: " + System.getProperty("javafx.runtime.version"));
      launch(args);
      }

      @Override
      public void start(Stage primaryStage) throws Exception {
              BorderPane bp = new BorderPane(new TextField());
      bp.setOnKeyPressed(e -> {
      primaryStage.close();
      try {
      DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      } catch (ParserConfigurationException e2) {
      e2.printStackTrace();
      }
      });
      primaryStage.setScene(new Scene(bp));
      primaryStage.show();
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Not known at this time

      FREQUENCY : always


            mfox Martin Fox
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: