On Mon, 3 Nov 2025 21:48:30 GMT, Harshitha Onkar <[email protected]> wrote:
>> test/jdk/javax/swing/regtesthelpers/Util.java line 1:
>>
>>> 1: /*
>>
>>> Existing `Util.findSubComponent()` finds component by class name
>>
>> To eliminate code duplication, the existing `findSubComponent` should use
>> the new `findComponent` which is more flexible. Just pass
>> `parent.getClass().getName().contains(className)` as the predicate to the
>> new method.
>
> Tested by in turn calling findComponent() from findSubComponent() it does not
> work as expected since the recursive logic to find the component differs for
> both methods.
>
> Replacing findSubComponent() as below with the latest changes does not work.
> To verify run javax/swing/JColorChooser/Test7194184.java by replacing the
> findSubComponent() as below.
>
>
> public static Component findSubComponent(Component parent, String
> className) {
> String parentClassName = parent.getClass().getName();
>
> if (parentClassName.contains(className)) {
> return parent;
> }
> return findComponent((Container) parent,
> c ->
> parent.getClass().getName().contains(className));
> }
It fails because the code I proposed is plainly wrong.
public static Component findSubComponent(Component parent, String
className) {
return findComponentImpl((Container) parent,
c ->
c.getClass().getName().contains(className));
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27944#discussion_r2490504845