-
CSR
-
Resolution: Approved
-
P4
-
None
-
source
-
minimal
-
-
Java API
-
JDK
Summary
Add the method canStartNestedEventLoop to the Platform class to provide a method for checking whether it is safe to start a nested event loop or not.
Problem
JavaFX provides methods to enter or exit a nested event loop via the Platform class. It is also possible to check if a nested event loop is running. JavaFX also uses these methods in the dialog or print API.
Before a nested event loop can be started, a check is performed: Toolkit.getToolkit().canStartNestedEventLoop. If this check returns false, an exception is thrown. Since Toolkit is private sun API, one should not use this method and therefore is not able to check this condition before attempting to enter a nested event loop (either directly or indirectly).
Solution
Add the method canStartNestedEventLoop to the Platform class, so that developers are able to check if it is safe to start a nested event loop or not without using private API. This is also the last missing method that deals with nested event loops and is not included in the Platform class.
Specification
/**
* Indicates whether a nested event loop can be started from the current thread in the current state.
* A nested event loop can be started from an event handler or from a {@code Runnable} passed to
* {@link #runLater(Runnable)}.
* This method must be called on the JavaFX Application thread.
*
* @return {@code true} if a nested event loop can be started, and {@code false} otherwise.
*
* @throws IllegalStateException if this method is called on a thread other than the JavaFX Application Thread.
*
* @since 21
*/
public static boolean canStartNestedEventLoop() {
...
}
- csr of
-
JDK-8302355 Public API for Toolkit.canStartNestedEventLoop()
- Resolved