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).

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

Commit messages:
 - 8385367: stop using stale/orphaned AccessibleContext

Changes: https://git.openjdk.org/jdk/pull/31271/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=31271&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8385367
  Stats: 68 lines in 2 files changed: 67 ins; 0 del; 1 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

Reply via email to