RFR: 8371657: [macosx] Programmatically selecting/deselecting List item triggers an ItemEvent [v2]

Sergey Bylokhov serb at openjdk.org
Thu Nov 27 21:49:07 UTC 2025


> When I was working on [JDK-8369327](https://bugs.openjdk.org/browse/JDK-8369327) I got a suggestion to update the code that disables unnecessary events:
> https://github.com/openjdk/jdk/pull/27682#discussion_r2487686109
> 
> After checking that code more closely, I found that it does not work in all cases. The checks were first added in [JDK-7125456](https://bugs.openjdk.org/browse/JDK-7125456). It looks like only the case for the select method was fixed. Other cases still cause unnecessary events, and even more events happen when trying to add multi selection mode: https://github.com/openjdk/jdk/pull/27682#issuecomment-3487434403
> 
> So I made a new bug for this issue and fixed it separately.
> 
> The [spec](https://github.com/openjdk/jdk/blob/8531fa146be1da5e96c0f23091882a27c67d7893/src/java.desktop/share/classes/java/awt/List.java#L899):
> 
>   * Adds the specified item listener to receive item events from
>   * this list.  Item events are sent in response to user input, but not
>   * in response to calls to {@code select} or {@code deselect}.
> 
> 
> The new test checks most of the methods in the `java.awt.List` class. It passes on linux/windows, confirming that the same behavior is implemented in other toolkits (unfortunately on linux it is not stable enough so I had to problemlist it due to [JDK-8201307](https://bugs.openjdk.org/browse/JDK-8201307)). The test only checks for programmatic changes to the list. I am sure that if I change it to test mix of programmatic/user changes it will fail. I will work on that in a follow up bug.
> 
> @aivanov-jdk @azvegint please take a look

Sergey Bylokhov has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - Merge branch 'openjdk:master' into JDK-8371657
 - Disable the new test on Linux due to 8201307
 - Merge branch 'openjdk:master' into JDK-8371657
 - 8371657: [macosx] Programmatically selecting/deselecting List item triggers an ItemEvent

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/28245/files
  - new: https://git.openjdk.org/jdk/pull/28245/files/e4ca5019..5f7e55c0

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=28245&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=28245&range=00-01

  Stats: 75549 lines in 1172 files changed: 50313 ins; 17042 del; 8194 mod
  Patch: https://git.openjdk.org/jdk/pull/28245.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28245/head:pull/28245

PR: https://git.openjdk.org/jdk/pull/28245


More information about the client-libs-dev mailing list