RFR: 6726690: SwingUtilities.replaceUI*Map() methods do not remove previously installed maps [v2]

Prasanta Sadhukhan psadhukhan at openjdk.org
Tue Dec 9 00:36:24 UTC 2025


On Mon, 8 Dec 2025 14:53:03 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:

>> Prasanta Sadhukhan has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Redundant code remove
>>  - Redundant code remove
>
> src/java.desktop/share/classes/javax/swing/SwingUtilities.java line 1820:
> 
>> 1818:                 if (uiInputMap == null) {
>> 1819:                     map.clear();
>> 1820:                 }
> 
> What if `if (parent == null || (parent instanceof UIResource)) {` is false and `uiInputMap == null`?
> Should we also clear the map?

Addressed..

> test/jdk/javax/swing/SwingUtilities/UIMapTest.java line 51:
> 
>> 49: 
>> 50:         // Add the map
>> 51:         SwingUtilities.replaceUIInputMap(button, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
> 
> Although the fix changes both `replaceUIInputMap` and `replaceUIActionMap`, only `replaceUIInputMap` is tested.

ActionMap test added

> test/jdk/javax/swing/SwingUtilities/UIMapTest.java line 58:
> 
>> 56:         // Show the frame
>> 57:         JFrame frame = new JFrame("UIMapTest");
>> 58:         frame.add(button);
> 
> Do we really need this?
> 
> Suggestion:
> 
> 
> 
> In its current state, the test will fail on headless systems because the test does not have the `@key headful`.

fixed

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28671#discussion_r2600629412
PR Review Comment: https://git.openjdk.org/jdk/pull/28671#discussion_r2600630154
PR Review Comment: https://git.openjdk.org/jdk/pull/28671#discussion_r2600630441


More information about the client-libs-dev mailing list