RFR: 8369306: Implement invokeAndWait and finishTerminating on headless platform [v3]

Jose Pereda jpereda at openjdk.org
Fri Oct 10 12:56:07 UTC 2025


On Fri, 10 Oct 2025 11:43:44 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> Jose Pereda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Process feedback from reviewer
>
> tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplication1Test.java line 45:
> 
>> 43:     @BeforeAll
>> 44:     public static void setup() throws Exception {
>> 45:         System.setProperty("glass.platform", "Headless");
> 
> I recommend also setting `"prism.order=sw"`.

Done

> tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplication1Test.java line 57:
> 
>> 55:             assertTrue(Platform.isFxApplicationThread());
>> 56:             new Thread(() -> {
>> 57:                 assertFalse(Platform.isFxApplicationThread());
> 
> Btw, an Exception or Error in this thread won't propagate to the test runner, so if this assertion ever fails it would print the exception, but not cause the test to fail. The test will timeout anyway if this happens, so it should be fine.

Right, I've moved the other assert before the count down, so if that one fails, it times out as well.

> tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplication2Test.java line 39:
> 
>> 37:     @BeforeAll
>> 38:     public static void setup() throws Exception {
>> 39:         System.setProperty("glass.platform", "Headless");
> 
> I recommend also setting `"prism.order=sw"`.

Done

> tests/system/src/test/java/test/com/sun/glass/ui/headless/HeadlessApplication2Test.java line 49:
> 
>> 47:             Platform.runLater(Platform::exit);
>> 48:         });
>> 49:         Util.sleep(10);
> 
> Is 10msec enough?

I'm testing on an M1, but you are right, on different environments it could take longer.

I've added now an exit latch from `PlatformImplShim.test_getPlatformExitLatch()`, so we wait whatever is needed until `PlatformImpl.tkExit()` finishes, and then those 10 ms should be more than enough (but we still need to wait a couple of ms nonetheless until the JavaFX thread is fully gone).

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2419937376
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2420000718
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2419938352
PR Review Comment: https://git.openjdk.org/jfx/pull/1934#discussion_r2419959876


More information about the openjfx-dev mailing list