Details
-
Bug
-
Resolution: Fixed
-
P3
-
8u20
-
None
Description
Starting with Java 8u20, we get this error, when halting the VM:
Exception in thread "Thread-4" java.lang.IllegalStateException: Attempt to call defer when toolkit not running
at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:646)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:285)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:261)
at javafx.application.Platform.runLater(Platform.java:78)
I don't see a way to check if the Toolkit is running or not. So the only possibility is to wrap the Platform.runLater call in a try-catch?
Testcase: Click Button.
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class TestApp2 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
}
});
}
});
Button button = new Button("Click");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.exit(0);
}
});
Scene scene = new Scene(button);
stage.setScene(scene);
stage.show();
}
}
I also saw this error, after shutting down the VM, but I can't get to reproduce it with the above Testcase:
java.lang.NullPointerException
at com.sun.javafx.tk.quantum.QuantumToolkit.isSupported(QuantumToolkit.java:1044)
at com.sun.javafx.application.PlatformImpl.isSupportedImpl(PlatformImpl.java:713)
at com.sun.javafx.application.PlatformImpl.isSupported(PlatformImpl.java:468)
at javafx.application.Platform.isSupported(Platform.java:163)
at javafx.scene.Scene.getEffectiveCamera(Scene.java:957)
at javafx.scene.Scene.pick(Scene.java:1898)
at javafx.scene.Scene.access$6700(Scene.java:144)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3673)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3447)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1723)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2456)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$126(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/33481228.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "Thread-4" java.lang.IllegalStateException: Attempt to call defer when toolkit not running
at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:646)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:285)
at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:261)
at javafx.application.Platform.runLater(Platform.java:78)
I don't see a way to check if the Toolkit is running or not. So the only possibility is to wrap the Platform.runLater call in a try-catch?
Testcase: Click Button.
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class TestApp2 extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
Platform.runLater(new Runnable() {
@Override
public void run() {
}
});
}
});
Button button = new Button("Click");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.exit(0);
}
});
Scene scene = new Scene(button);
stage.setScene(scene);
stage.show();
}
}
I also saw this error, after shutting down the VM, but I can't get to reproduce it with the above Testcase:
java.lang.NullPointerException
at com.sun.javafx.tk.quantum.QuantumToolkit.isSupported(QuantumToolkit.java:1044)
at com.sun.javafx.application.PlatformImpl.isSupportedImpl(PlatformImpl.java:713)
at com.sun.javafx.application.PlatformImpl.isSupported(PlatformImpl.java:468)
at javafx.application.Platform.isSupported(Platform.java:163)
at javafx.scene.Scene.getEffectiveCamera(Scene.java:957)
at javafx.scene.Scene.pick(Scene.java:1898)
at javafx.scene.Scene.access$6700(Scene.java:144)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3673)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3447)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1723)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2456)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$126(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/33481228.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Attachments
Issue Links
- relates to
-
JDK-8095201 JavaFx Application crashes on Exit
- Resolved
-
JDK-8093775 Document that FX toolkit should not be used by application shutdown hooks
- Resolved
-
JDK-8095885 Need unit test that calls Platform.runLater from ShutdownHook
- Resolved
-
JDK-8088550 Simple WebEngine application is undeterministic (works/works very slowly/hangs/throws exception)
- Open