On Mon, 30 Mar 2026 23:47:27 GMT, Jeremy Wood <[email protected]> wrote:

>> src/java.desktop/share/classes/javax/swing/JEditorPane.java line 1727:
>> 
>>> 1725:             if (axText == null) {
>>> 1726:                 axText = new JEditorPaneAccessibleHypertextSupport();
>>> 1727:                 
>>> JEditorPane.this.addPropertyChangeListener("document", evt -> axText = null 
>>> );
>> 
>> Will we accumulate these listeners overtime? (since each 
>> getAccessibleText->setDocument->getAccessibleText will re-add the new one).
>
> That depends on what you mean by "we".
> 
> If getDocument() is always a new document: I'm not worried about accumulating 
> listeners. Some old listeners will be left attached to old orphaned 
> Documents, but I'm not even sure if that's a bad thing. (If a JTextComponent 
> doesn't reference a Document anymore, does that guarantee no other entity can 
> have a reasonable interest in it?)
> 
> But I think this usage is going to be problematic:
> 
> HTMLDocument doc1, doc2;
> ...
> for (int a = 0; a < 1000; a++) {
>     textPane.setDocument(a%2 == 0 ? doc1 : doc2);
>     textPane.getAccessibleContext().getAccessibleText();
> }
> 
> 
> But I chose not to address that in this PR because (to me) that feels like 
> feature creep for the original ticket. 
> 
> Would you like me to address that here? (This PR is currently changing ~5 
> lines, but a bigger refactor may change close to 20-30?)
> 
> (Or are you asking about something different?)

Here is my ideal refactor for this ticket. (It should manage listeners more 
reliably.) But my gut says not to go this route because it's too 
invasive/ambitious, especially given the original complaint.

https://github.com/openjdk/jdk/compare/master...mickleness:8380790B?expand=1

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30401#discussion_r3012909756

Reply via email to