On Mon, 16 Sep 2024 09:55:19 GMT, Alexey Ivanov <[email protected]> wrote:

> This changeset refactors `java/awt/event/KeyEvent/FunctionKeyTest.java`.
> 
> Key changes:
> 
> - Use `CyclicBarrier` to verify whether a key is pressed and released;
> - Use `CountDownLatch` for frame activation;
> - Ensure thread-safety for keeping thrown exceptions.
> 
> Other changes:
> 
> - Made `FunctionKeyTester` a nested class inside `FunctionKeyTest`;
> - Used constants for the key events rather than magic numbers.
> 
> I ran the updated test a few times with `JTREG=REPEAT_COUNT=20`, the test has 
> passed.
> 
> The updated test executes somewhat quicker than the old one.
> 
> @azvegint, you may want to take a look.

test/jdk/java/awt/event/KeyEvent/FunctionKeyTest.java line 70:

> 68:     public static void main(String[] args) throws Exception {
> 69:         robot = new Robot();
> 70:         robot.setAutoWaitForIdle(true);

This makes the updated test run slower because the barriers block EDT for a 
short while until the two threads — EDT and main thread — arrive to the same 
point.

`robot.waitForIdle` blocks the main thread from arriving to the barrier and 
*releasing EDT*.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21013#discussion_r1760867438

Reply via email to