Looks like the problem occurs when system is slow to actually close windows, then keyboard events are going to the wrong window. The idea of the fix is to bring the new window to front before actual testing starts and close window on EDT and then wait for 2 seconds for actual hardware window to disappear.
------------- Commit messages: - 8202667: java/awt/Debug/DumpOnKey/DumpOnKey.java times out on Windows Changes: https://git.openjdk.java.net/jdk/pull/6194/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6194&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8202667 Stats: 14 lines in 2 files changed: 10 ins; 1 del; 3 mod Patch: https://git.openjdk.java.net/jdk/pull/6194.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/6194/head:pull/6194 PR: https://git.openjdk.java.net/jdk/pull/6194