On Wed, 23 Nov 2022 06:54:25 GMT, Srinivas Mandalika <smandal...@openjdk.org> wrote:
>> test/jdk/java/awt/EventDispatchThread/InterruptEDTTest.java line 66: >> >>> 64: frame.setVisible(true); >>> 65: }); >>> 66: ((sun.awt.SunToolkit) >>> (Toolkit.getDefaultToolkit())).realSync(); >> >> You can use the Robot.waitForIdle instead of realSync since jdk9. > > There was a comment in the original code before the realSync() call that was > removed, which perhaps should have been left as is. > // cannot substitute with robot.waitForIdle() presumably because of > flushPendingEvents() there > My understanding of above is that for simulating the test scenario - which is > - Events (on line 75,76,77) are triggered and while these are potentially not > yet complete(as they are wrapped in an invokeLater), the edt is interrupted. > > When run on jdk7u6 - the UI hangs and SOP of line 59 is not invoked. > When run on jdk7u361 b01 the SOP on line 59 is printed and also the test > passed. > > waitForIdle here will trigger the flushPendingEvents internally before the > edt interrupt call -and that would eliminate any possibility of simulating > the above scenario. Then please double-check how robot.waitForIdle() and realSync() affect the test, since both call the flushPendingEvents(), why there is a difference? * robot.waitForIdle()->SunToolkit.flushPendingEvents(); * realSync()->waitForIdle()->flushPendingEvents >> test/jdk/java/awt/EventDispatchThread/InterruptEDTTest.java line 80: >> >>> 78: }); >>> 79: } catch (Exception e) { >>> 80: e.printStackTrace(); >> >> Why do we skip an exception here and in another place below? > > As described in the comment above, the intent of the test is to validate the > absence of a failure via a test hang and not via an exception. But if some exception will be thrown there it should not ignore it and just pass. ------------- PR: https://git.openjdk.org/jdk/pull/10784