On Fri, 24 Jan 2025 18:44:43 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:
>> Alisen Chung has updated the pull request incrementally with one additional >> commit since the last revision: >> >> init finX, finY > > src/java.desktop/share/classes/java/awt/Robot.java line 175: > >> 173: for (int i = 0; i < gs.length; i++) { >> 174: allScreenBounds[i] = >> gs[i].getDefaultConfiguration().getBounds(); >> 175: } > > This doesn't look right to me… `init` is an instance method, yet it > initialises `allScreenBounds` which is shared among all instances. > > In a way it makes sense to share the graphics environment / configuration. On > the other hand how much would it affect the operation of robot if the bounds > are fetched from `GraphicsEnvironment` only when needed? > > What happens if the graphics configuration changes? Does the user need to > create a new instance of the `Robot` class? I did consider this and thought it would be too expensive to fetch the bounds on every mouseMove action, so i thought it would be better to reinitialize robot when the graphics configuration changes. Do you have a better idea for where/when to cache the bounds? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/22781#discussion_r1932683280