On Tue, 4 Nov 2025 13:22:33 GMT, Alexey Ivanov <[email protected]> wrote:

>> 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));
>     }

I would even format it like this, wrapping all the chained calls:


    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_r2490509126

Reply via email to