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

Uncaught exception in static initializer for Control prevents creation of all controls

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • Mac OS X 10.7.5; JDK 1.8.0 ea b101.

      If an attempt is made to create a Control off the JavaFX Application Thread before any other Controls are created, an uncaught exception is generated in the static initializer of Control. This prevents creation of any controls. See the OTN discussion at https://forums.oracle.com/thread/2568357

      Thanks to jsmith for the analysis.

      To recreate the problem, run the following sample code, also courtesy of jsmtih.

      import javafx.application.Application;
      import javafx.concurrent.Task;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;
      import java.util.concurrent.ExecutorService;
      import java.util.concurrent.Executors;
      public class ControlBreak extends Application {
          @Override
          public void start(Stage stage) throws Exception {
              final StackPane layout = new StackPane();
              stage.setScene(new Scene(layout));
              stage.show();
              ExecutorService exec = Executors.newSingleThreadScheduledExecutor();
              exec.submit(new Task<Label>() {
                  {
                      setOnSucceeded(event -> layout.getChildren().add(getValue()));
                      setOnFailed(event -> getException().printStackTrace());
      }
                  @Override
                  protected Label call() throws Exception {
                      return new Label("xyzzy");
                  }
              });
              exec.shutdown();
          }
          public static void main(String[] args) { launch(); }
      }

            jgiles Jonathan Giles
            jdenvirjfx James Denvir (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: