New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8263322: Calling Application.launch on FX thread should throw IllegalStateException, but causes deadlock #421
Conversation
Fixing deadlock when calling Application.launch in the FXThread after Platform.launch
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
Webrevs
|
/reviewers 2 |
@kevinrushforth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind the fix is good. A few changes are needed:
-
The check should be split into two separate
if
statements, each with their own error message (see inline). -
This should be documented in the API docs for the Application::launch method as an additional case that will throw an IllegalStateException. It will need a reasonably trivial CSR since we are specifying a new case that will cause an exception to be thrown.
-
The system test need to be broken up into separate files, one for each
@Test
method, since application launching tests need to run in their own JVM. If you want to share any code, you could refactor it into a common class that has methods (not annotated with@Test
) to perform the testing, and separate classes that will subclass the common class, each with a single@Test
method that simply calls into the method in the common class to do the testing. See any number of examples intests/system/src/test/java/test/com/sun/javafx/application/
(which is also a better location for your new test). You will want to add a cleanup method annotated with@AfterClass
that callsPlatform.exit()
. I think three tests would be good:- Initalize the FX runtime via Platform.startup and then launch an Application on another thread (should succeed)
- Initalize the FX runtime via Platform.startup and then launch an Application
on another threadthe FX Application Thread (should throw ISE) - Initalize the FX runtime via Application.launch and then launch a second Application on another thread (should throw ISE).
I note that when I run your test, it hangs (on Windows...I didn't try it on other platforms).
gradle --info -PFULL_TEST=true cleanTest :systemTests:test --test InitializeJavaFXTest
This might be resolved by ensuring each test is in its own JVM as requested above.
Additional comments are inline.
modules/javafx.graphics/src/main/java/com/sun/javafx/application/LauncherImpl.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/scene/InitializeJavaFXTest.java
Outdated
Show resolved
Hide resolved
/csr |
@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request. |
That should be:
|
Contribution.MD states, that it's automatically checked for whitespace errors? Is this not true? As a clarification, this PR restores the previous behavior before Platform.startup. With this PR Application.launch and Platform.startup behaves the same. |
Small changes based on code review
Small changes based on code review
Added missing change
I forgot to commit a part of the fix, which is why the second test hang. It's now part of the PR. |
About the CSR: |
Added the tests for both cases, when JavaFX was initialized with Application.launch and Platform.startup
I've now restructured the tests. |
Yes, Skara's jcheck does basic sanity checking (tabs, trailing white space, line endings). Why do you ask? I didn't raise this as a question in this PR. Do you have reason to believe that this isn't working?
Not quite. |
No, this really should succeed. Internally, it is a similar case to what the special Java launcher method does when launching a Java class that extends |
To further clarify, Note this from the
|
Not quite. See my reply above.
Almost. Go to your bug in JBS, and use the "More" pull-down menu. There is a "Create CSR" option. |
Updated the unit-test so they match the wanted behavior discussed in the PR
removed unused imports, added missing change
modules/javafx.graphics/src/main/java/com/sun/javafx/application/LauncherImpl.java
Outdated
Show resolved
Hide resolved
@kevinrushforth The command |
28 similar comments
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
@kevinrushforth The command |
Looks like the Skara bot is in a loop continually reprocessing the |
Fixing deadlock when calling Application.launch in the FXThread after Platform.startup
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/421/head:pull/421
$ git checkout pull/421
Update a local copy of the PR:
$ git checkout pull/421
$ git pull https://git.openjdk.java.net/jfx pull/421/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 421
View PR using the GUI difftool:
$ git pr show -t 421
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/421.diff