On Tue, 31 Mar 2026 01:01:58 GMT, Jeremy Wood <[email protected]> wrote:

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

That solution above seems too complicated. Note that the patch updates the 
AccessibleJEditorPaneHTML class which is used only if current kit is 
HTMLEditorKit, so if the user sets the non-html-EditorKit or new Document we 
should drop the current accessibleContext and create a new one?

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

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

Reply via email to