On Tue, 9 Dec 2025 00:36:21 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> `SwingUtilities.replaceUIInputMap()` and 
>> `SwingUtilities.replaceUIActionMap()` do not actually remove previously 
>> installed maps as their Javadoc indicates if `null` is passed as 
>> `uiInputMap`/`uiActionMap`
>> 
>> https://github.com/openjdk/jdk/blob/7e91d34f3e83b4c39d6ce5de34373d7d74d54512/src/java.desktop/share/classes/javax/swing/SwingUtilities.java#L1802-L1803
>> https://github.com/openjdk/jdk/blob/7e91d34f3e83b4c39d6ce5de34373d7d74d54512/src/java.desktop/share/classes/javax/swing/SwingUtilities.java#L1827-L1828
>> 
>> If the passed  `uiInputMap`/`uiActionMap` is null, `JComponent` actually 
>> doesn't create a fresh map and returns the previously installed map 
>> https://github.com/openjdk/jdk/blob/7e91d34f3e83b4c39d6ce5de34373d7d74d54512/src/java.desktop/share/classes/javax/swing/JComponent.java#L2586-L2595
>> which is in contradiction to the `replaceUI*Map` spec so `SwingUtilities 
>> `needs to clear the previously installed map which is being done in this fix.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Fix update...ActionMap test added

This change worries me. How was it tested ?
I see MANY places (dozens and dozens) that Swing internally passes null to 
these calls.
The behaviour of these is now changed. 
@prsadhuk please explain how this is a safe change and if you examined all of 
the usages of this with null ?

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

PR Comment: https://git.openjdk.org/jdk/pull/28671#issuecomment-3638305053

Reply via email to