RFR: 8322784: JFXPanel calls InputMethodRequests on wrong thread [v2]

Martin Fox mfox at openjdk.org
Mon Jan 22 20:55:38 UTC 2024


On Mon, 22 Jan 2024 15:45:25 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Either an array or an AtomicReference is OK in this case. AtomicReference is thread-safe, but that's not a concern here, since using `runAndWait` ensures that writing to the array happens before reading it.
>
> I might be wrong, but array would need to store its size (an int, 8 bytes on 64 bit machines) in addition to the pointers themselves, while AtomicReference needs just the pointer.
> Plus, its semantics is much cleaner.

Again, thread-safety isn't an issue here. Even if the OS were to invoke the IM methods on different threads (which is a terrifying thought) these adapters are created on a per-call basis so each thread would get its own instance. This also means those extra eight bytes are transitory.

If there's an established JavaFX pattern of using AtomicReference instead of an array I will gladly make the changes. But this does require manual testing (I still haven't figured out how to automate this) so I'm reluctant to do this based on personal style preferences.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1337#discussion_r1462403040


More information about the openjfx-dev mailing list