On Fri, 24 Oct 2025 11:27:03 GMT, Alexey Ivanov <[email protected]> wrote:

>> There are some tests where EDT calls are interleaved between calls to robot 
>> (non-EDT) (e.g bug4759934.java - findCancelButton()) and few other tests 
>> (e.g FileSizeCheck.java - findDetailsButton() and findTable() that are 
>> within upper level method which is called on EDT). Is it better to leave it 
>> as-is for flexibility rather than add a wrapper?
>> 
>> If a wrapper is added we might need to check if it is already on EDT thread 
>> or not as below:
>> 
>> 
>> if (isEventDispatchThread()) {
>>    return _findComponent(container, predicate);
>> } else {
>>   return Util.invokeOnEDT(() -> _findComponent(container, predicate));
>> }
>
>> If a wrapper is added we might need to check if it is already on EDT thread 
>> or not as below:
> 
> This is what I said: *“the implementation will run directly or on EDT.”* So 
> if it's already on EDT, call directly; it it's not, use `invokeOnEDT`.
> 
> The utility method can then be used in all the contexts without thinking. 
> (The implementation, if you choose this way, should rather be 
> `findComponentImpl` rather than prefixed with an underscore.)
> 
> Likely, one still needs to call `findComponent` on EDT because any other 
> operations on the component need to be on EDT. In this case, `findComponent` 
> could throw an exception if it's called not on EDT.
> 
> These things will ensure the method can work correctly.

Updated.

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

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

Reply via email to