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

Kevin Rushforth kcr at openjdk.org
Fri Jul 25 21:23:02 UTC 2025


On Mon, 7 Jul 2025 09:15:47 GMT, Johan Vos <jvos at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/headless/HeadlessRobot.java line 231:
>> 
>>> 229:         if (windows.isEmpty()) return null;
>>> 230:         if (windows.size() == 1) return (HeadlessWindow)windows.get(0);
>>> 231:         return (HeadlessWindow)windows.get(windows.size() -1);
>> 
>> call me old fashioned, but would a straightforward reverse `for` loop be better in this case?  no unnecessary memory allocations required.
>> 
>> here and in two methods below?
>
> I'm not a fan of using Streams if it's not really needed, but in this case I think there might be benefits in eliminating the non-candidates in 1 statement -- I might be wrong though, didn't look yet at how this is compiled.

I think this is fine as is. I do note that the following is redundant:


        if (windows.size() == 1) return (HeadlessWindow)windows.get(0);


The general case will handle this case (and should be just as efficient).

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1836#discussion_r2231976178


More information about the openjfx-dev mailing list