RFR: 8324941: POC for Headless platform for JavaFX [v2]

Johan Vos jvos at openjdk.org
Mon Jun 23 08:19:37 UTC 2025


On Thu, 19 Jun 2025 22:36:14 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> Johan Vos has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix missing ;
>
> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessApplication.java line 29:
> 
>> 27:     private final int MULTICLICK_MAX_X = 20;
>> 28:     private final int MULTICLICK_MAX_Y = 20;
>> 29:     private final long MULTICLICK_TIME = 500;
> 
> These fields should be `static`.

done

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessPlatformFactory.java line 52:
> 
>> 50:     }
>> 51: 
>> 52:     class HeadlessSystemClipboard extends SystemClipboard {
> 
> This class can be `static`.

done

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessPlatformFactory.java line 92:
> 
>> 90:     }
>> 91: 
>> 92:     class HeadlessDnDClipboard extends SystemClipboard {
> 
> This class can be `static`.

done

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessRobot.java line 213:
> 
>> 211:             HeadlessView view = (HeadlessView)activeWindow.getView();
>> 212:             int modifiers = 0;
>> 213:             view.notifyMouse(MouseEvent.ENTER, MouseEvent.BUTTON_NONE, (int)mouseX-wx, (int)mouseY-wy, (int)mouseX, (int)mouseY, modifiers, true, true);
> 
> Minor: spacing around operators

aligned with com.sun.glass.ui.Window

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessRobot.java line 219:
> 
>> 217:                     int owx = oldWindow.getX();
>> 218:                     int owy = oldWindow.getY();
>> 219:                     oldView.notifyMouse(MouseEvent.EXIT, MouseEvent.BUTTON_NONE, (int)mouseX-owx, (int)mouseY-owy, (int)mouseX, (int)mouseY, modifiers, true, true);
> 
> Minor: spacing around operators

formatted

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessTimer.java line 11:
> 
>> 9: 
>> 10:     private static ScheduledThreadPoolExecutor scheduler;
>> 11:     private ScheduledFuture task;
> 
> You can use the parameterized type `ScheduledFuture<?>`.

done

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessView.java line 46:
> 
>> 44:     @Override
>> 45:     protected void _setParent(long ptr, long parentPtr) {
>> 46:         parentPtr = parentPtr;
> 
> You're assigning a variable to itself. But even if you qualify `this.parentPtr`, the assignment seems pointless.

Added this -- I agree it looks pointless now, but preparing for follow-up review comments where the parentPtr is prepared.

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessWindow.java line 106:
> 
>> 104:             this.originalY = this.y;
>> 105:             newX = 0;
>> 106:             newY = 0;
> 
> `newX` and `newY` already have the value 0.

removed

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessWindow.java line 350:
> 
>> 348:                 int val = intBuffer.get(i * pixels.getWidth() + j);
>> 349:                 if (val != 0) {
>> 350:                 }
> 
> The `if` statement has an empty body.

removed

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessWindowManager.java line 22:
> 
>> 20:     }
>> 21: 
>> 22:     private HeadlessWindow getFocusedWindow() {
> 
> This private method is never used.

removed

> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/NestedRunnableProcessor.java line 61:
> 
>> 59:             } catch (Throwable e) {
>> 60:                 e.printStackTrace();
>> 61:                 Application.reportException(e);
> 
> Why do you print the exception, _and_ send it to `Application.reportException()`? The latter already sends it to the uncaught exception handler, where it is printed by default.

removed

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160990536
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160991962
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160992138
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160983234
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160983924
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160996768
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160998776
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160987621
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160979955
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2161000643
PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2160980898


More information about the openjfx-dev mailing list