On Tue, 7 Apr 2026 01:44:45 GMT, Jeremy Wood <[email protected]> wrote:
>> This PR automatically calls CAccessible.dispose() as Components are removed >> from the AWT hierarchy. Then as Components are readded later: we recreate a >> new CAccessible. >> >> I couldn't figure out how CAccessible.dispose() was ever meant to be called >> before. (It exists because CFRetainedResource#dispose() exists.) I added >> debugger breakpoints and never saw it invoked. >> >> This PR focuses on the life cycle of a CAccessible, so it also adds logic in >> the dispose() method to remove a listener and nullify cached info. >> >> I don't have a great understanding of this area of code / subject matter, >> but this appears to resolve #8381236. >> >> --------- >> - [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 seven additional > commits since the last revision: > > - 8381236: fixing whitespace > - 8381236: remove AXChangeNotifier after dispose > > This PR really focuses on controlling the lifecycle of a CAccessible, so > if we're encouraging them to be disposed more often: we should also uninstall > our listeners. > - 8381236: tweak comment > - 8381236: make new method private > - 8381236: remove unused import > - 8381236: move static field above non-static fields > - 8381236: refactor to use "ancestor" listener > > Using "ancestor" listener makes a little more sense: each individual > component can dispose of its own CAccessible. (Instead of relying on a parent > to dispose its descendants recursively.) > > Also I poked around with debugger breakpoints and realized CAccessibles > are not automatically getting recreated as quickly as I'd like so: > A. I recreate them myself when the Component is reattached to a hierarchy > B. I cleared the cache (setNativeAXResource(null)) to make sure the new > CAccessible gets used src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java line 102: > 100: @Override > 101: public void propertyChange(PropertyChangeEvent evt) { > 102: Component comp = (Component) evt.getSource(); Couldn't you just replace these 6 lines with simple `if (evt.getSource() instanceof Accessible ax) {` that will make code much cleaner. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/30578#discussion_r3120285255
