> 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 one additional 
commit since the last revision:

  8381236: refactor proposed solution
  
  I still don't understand the life cycle of a CAccessible, but I'm starting to 
think this simpler approach may be better.
  
  It seems like:
  A. We never discard a CAccessible. Once CAccessible 'Y' is constructed, it 
will forever be paired with (and referenced by) its AccessibleContext 'X'. 
(Therefore the listeners that 'Y' installs never need to be uninstalled.)
  B. Some external entity is defining `CAccessible#ptr`. We don't receive a 
call to `setPtr`, and it's not defined during construction. But at some point 
as VoiceOver interacts with a Swing app the `ptr` field is defined.
  C. It appears safe to call `dispose()` repeatedly on the same CAccessible. So 
in this way `dispose()` is like `Window.dispose()`: it releases resources, but 
it can be reallocated later (by some external agent). (By contrast it is NOT 
like `Graphics2D.dispose()`; subsequent attempts to use a Graphics2D will fail 
after it has been disposed.)

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/30578/files
  - new: https://git.openjdk.org/jdk/pull/30578/files/26135316..c0b0f477

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=30578&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=30578&range=02-03

  Stats: 57 lines in 1 file changed: 0 ins; 48 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/30578.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/30578/head:pull/30578

PR: https://git.openjdk.org/jdk/pull/30578

Reply via email to