RFR: JDK-8353755 : Add a helper method to Util - findComponent() [v3]

Alexey Ivanov aivanov at openjdk.org
Tue Nov 4 13:49:20 UTC 2025


On Tue, 4 Nov 2025 13:24:01 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

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

I also suggest calling `findComponent` instead of `findComponentImpl` — then you can remove the line *“Always run this method on the EDT thread”* from the javadoc comment.

Also, change “a sub component” to “a subcomponent”.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27944#discussion_r2490583144


More information about the client-libs-dev mailing list