> Calling `getAccessibleContext()` may in some cases replace the field > `accessibleContext`. So we should use `getAccessibleContext()` here to make > sure sure we have the most up-to-date AccessibleContext / DocumentListener. > > > ### Other Related Consideration > > The `setDocument()` method includes analogous logic for > `inputMethodRequestsHandler`. However `inputMethodRequestsHandler` is never > reassigned outside of the JTextComponent class, so that shouldn't require a > similar fix/change anytime soon. > > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Jeremy Wood has updated the pull request incrementally with one additional commit since the last revision: 8385367: make sure new DocumentListener is only added once In getAccessibleContext() when we create a new AccessibleContext: we immediately add it as a DocumentListener to our Document. So in that case: setDocument(..) doesn't need to add a DocumentListener. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/31271/files - new: https://git.openjdk.org/jdk/pull/31271/files/35603a7b..198a5fcd Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=31271&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31271&range=00-01 Stats: 27 lines in 2 files changed: 24 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/31271.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/31271/head:pull/31271 PR: https://git.openjdk.org/jdk/pull/31271
