Hi, Pete,
let me provide more information here.
There are two different bugs about the same problem:
7177111: Jcomponent.AccessibleJComponent.AddPropertyListeners adds
exponential listeners
7179482: Component.accessibleContext and JComponent.accessibleContext
refactoring
7177111 is targeted to 7u12, while 7179482 is for 8. The fix for 7u12 is
a sub-set of the fix for 8. The webrevs are available here:
http://cr.openjdk.java.net/~ptbrunet/7177111/webrev.03/
http://cr.openjdk.java.net/~ptbrunet/7179482/webrev.00/
The fix for 7177111 looks fine.
The fix for 7179482 doesn't. Every time a PCL is added to a Component
with addPropertyChangeListener(), we add the same Component/Container
listener to Component.this. As the listener is the same, it's actually
added only once. Now if one of PCLs is removed with a call to
removePropertyChangeListener(), accessibleComponent/ContainerHandler is
removed from Component.this, so all the rest PCLs will stop receiving
notifications.
Thanks,
Artem
On 11/9/2012 1:27 PM, Pete Brunet wrote:
Please review the following fix planned for JDK8. Part of the fix will
go into 7u12 under 7177111.
Problem:
In the process of evaluating 7177111 the following problems were noticed:
- Both Component and JComponent have field "accessibleContext". In
Component it is package-private and accessed by other classes from
java.awt, but in JComponent it is protected and therefore this field
hides the same superclass field from any subclass. These two fields
should be refactored to a single protected field in Component.
- Container.AccessibleAWTContainer has an addPropertyChangeListener but
not a removePropertyChangeListener. This method is needed so stale
listeners can be removed when AT are no longer attached to a Java process.
- The JComponent.AccessibleJComponent.accessibleFocusHandler field
functionally duplicates its superclass field,
Component.AccessibleAWTComponent.accessibleAWTFocusHandler. When this
field is used properly there are no logical issues. However, the
existence of this field could cause confusion for a developer trying to
understand the code. The superclass field is sufficient.
Solution:
- Change java.awt.Component.accessibleContext from package-private to
protected. This will allow use by subclasses and the removal of the
duplicate field in javax.swing.JComponent.
- Add
java.awt.Container.AccessibleAWTContainer.removePropertyChangeListener
so stale listeners can be removed when an Assistive Technology is no
longer attached to a Java process.
- Remove the protected field javax.swing.JComponent.accessibleContext.
Instead the protected field java.awt.Component.accessibleContext, will
be used. With the change subclasses would now use the protected field
in the Component superclass.
- Remove public method javax.swing.JComponent.getAccessibleContext.
Instead it superclass public method
java.awt.Component.getAccessibleContext method would be used.
- javax.swing.JComponent.AccessibleJComponent.accessibleFocusHandler
field will be deprecated. Developers should use the
java.awt.Component.AccessibleAWTComponent.accessibleAWTFocusHandler
field instead.
Webrev: http://cr.openjdk.java.net/~ptbrunet/7179482/webrev.00/
Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7179482
CCC: http://ccc.us.oracle.com/7179482