> 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 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 seven additional commits since the last revision: - 8385367: trying to fix whitespace for PR - 8385367: moving fix to JEditorPane This is in response to: https://git.openjdk.org/jdk/pull/31271#discussion_r3358850956 - 8385367: cleaning up test - Merge branch 'master' into 8385367 - Merge branch 'openjdk:master' into master - 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. - 8385367: stop using stale/orphaned AccessibleContext ------------- Changes: - all: https://git.openjdk.org/jdk/pull/31271/files - new: https://git.openjdk.org/jdk/pull/31271/files/198a5fcd..bac96689 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=31271&range=02 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=31271&range=01-02 Stats: 216830 lines in 2213 files changed: 102176 ins; 101311 del; 13343 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
