With this PR: We call `CAccessible.valueChanged` when we believe the value changed, not when the AccessibleStateSet changed.
Although this is a small refactor: it touches parts of code that span approximately a decade of different bug fixes. At least one of these older bugs was a P2. I tried to note the related issues in the test for reference. (Also in my testing I confirmed JRadioButtons and JToggleButtons work as expected, but I kept the final test simple for the convenience of human testers.) In 8377936 the problem was: We had two components, X and Y. When VO transferred the focus from X to Y, it would (ever so briefly) start to announce Y.** Then Swing would update X's AccessibleContext to inform it that X was no longer focused, therefore X's AccessibleStateSet changed. This triggered CAccessible's AXChangeNotifier, which called `CAccessible.valueChanged`. This resulted in VoiceOver announcing X's state (as if it thought the selected state changed), even though the keyboard focus was now on Y. The AXChangeNotifier was probably intending to call `valueChanged` only when AccessibleState.SELECTED or CHECKED or something important was updated. The fact that it called `valueChanged` for AccessibleState.FOCUSED is probably an oversight***. ** If you comment out the line in CAccessibility.requestFocus that actually requests the focus: then VoiceOver announced Y correctly. But this left the keyboard focus on the wrong component. *** I also tested triggering AccessibleState.FOCUSABLE, AccessibleState.VISIBLE, and a few other states; none of them resulted in a comparable bug, though. ------------- Commit messages: - 8377936: call valueChanged only for VALUE_PROPERTY changes Changes: https://git.openjdk.org/jdk/pull/30641/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=30641&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8377936 Stats: 127 lines in 2 files changed: 110 ins; 15 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/30641.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/30641/head:pull/30641 PR: https://git.openjdk.org/jdk/pull/30641
