<div dir="ltr"><div dir="ltr">Hi Martin,<br><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Thanks for your feedback and happy to hear that it worked!</div><div><br></div><div>In regards to <span style="font-size:12.8px">pendingEvents sync, my understanding is that SequencedEvent objects will be posted to one EventQueue only and, thus, be dispatched by one EDT.</span></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Agreed. <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I had a quick look at "Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source" exception and could not find any connection to the code modified in the context of this bug. Apparently, "activeWindow" variable in "WindowEvent.WINDOW_LOST_FOCUS" case is null (DefaultKeyboardFocusManager.dispatchEvent function</span><span style="font-size:12.8px">). I thought that this was caused by the fact that the test is injecting events that modify the focus on both windows at a very high rate and, by the time </span><span style="font-size:12.8px">DefaultKeyboardFocusManager dispatches the event, it could be too late. Just an hypothesis.</span></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I agree, it is certainly a side-effect: other issues may be triggered by such event intensive test.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><span style="font-size:12.8px"></span></div><div><span style="font-size:12.8px">Look forward to your re-written test.</span></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>Here it is:</div><div><span style="font-family:monospace,monospace"><br>import java.awt.BorderLayout;<br>import java.awt.Dimension;<br>import java.awt.event.ActionEvent;<br>import java.awt.event.ActionListener;<br>import java.util.ArrayList;<br>import java.util.List;<br>import java.util.concurrent.atomic.AtomicReference;<br>import javax.swing.JButton;<br><br>import javax.swing.JFrame;<br>import javax.swing.JLabel;<br>import javax.swing.SwingUtilities;<br>import javax.swing.Timer;<br><br>/*<br> * Running this code causes the AWT Event Queues to be blocked on OpenJDK11<br> * javac --add-exports java.desktop/sun.awt=ALL-UNNAMED TestWinEvent.java<br> *<br> * @author Laurent Bourges<br> */<br>public final class TestWinEvent extends JFrame implements ActionListener {<br><br>    private static final long serialVersionUID = 1L;<br><br>    private static final int NUM_WINDOW = 2;<br>    private static final int INTERVAL = 50;<br>    private static final int MAX_TIME = 10000; // 10s<br>    private static final int MAX_COUNT = MAX_TIME / INTERVAL;<br>    private static final List<TestWinEvent> WINDOWS = new ArrayList<TestWinEvent>();<br><br>    private final JButton btn;<br>    private int counter = 0;<br>    private final Timer t;<br><br>    public static void main(String[] args) {<br>        try {<br>            for (int i = 0; i < NUM_WINDOW; i++) {<br>                createWin(i + 1);<br>            }<br><br>            // Wait MAX_TIME + 2s<br>            Thread.sleep(MAX_TIME + 2000);<br><br>            int total = 0;<br>            for (TestWinEvent window : WINDOWS) {<br>                total += window.getCounter();<br>            }<br><br>            // Failure if AWT hanging: assert<br>            final int expected = MAX_COUNT * NUM_WINDOW;<br>            if (total != expected) {<br>                throw new IllegalStateException("Total [" + total + "] != expected [" + expected + "] !");<br>            }<br>        } catch (InterruptedException ie) {<br>            ie.printStackTrace();<br>        } catch (IllegalStateException iae) {<br>            iae.printStackTrace();<br>        } finally {<br>            System.exit(0);<br>        }<br>    }<br><br>    private static void createWin(int tgNum) {<br>        new Thread(new ThreadGroup("TG " + tgNum),<br>                new Runnable() {<br>            @Override<br>            public void run() {<br>                sun.awt.SunToolkit.createNewAppContext();<br><br>                final AtomicReference<TestWinEvent> ref = new AtomicReference<TestWinEvent>();<br><br>                SwingUtilities.invokeLater(new Runnable() {<br>                    @Override<br>                    public void run() {<br>                        final TestWinEvent window = new TestWinEvent(tgNum);<br>                        window.setVisible(true);<br>                        ref.set(window);<br>                        WINDOWS.add(window);<br>                    }<br>                });<br><br>                try {<br>                    // Wait 1s to show window<br>                    Thread.sleep(1000);<br>                } catch (InterruptedException ie) {<br>                    ie.printStackTrace();<br>                }<br><br>                final TestWinEvent window = ref.get();<br>                if (window != null) {<br>                    window.enableTimer(true);<br>                }<br>            }<br>        }).start();<br>    }<br><br>    TestWinEvent(final int num) {<br>        super("Test Window [" + num + "]");<br>        setMinimumSize(new Dimension(300, 200));<br>        setLocation(100 + 400 * (num - 1), 100);<br><br>        setLayout(new BorderLayout());<br>        JLabel textBlock = new JLabel("Lorem ipsum dolor sit amet...");<br>        add(textBlock);<br><br>        btn = new JButton("TEST");<br>        btn.addActionListener(new ActionListener() {<br>            @Override<br>            public void actionPerformed(ActionEvent e) {<br>                System.out.println("Button#" + num + " clicked: " + counter);<br>            }<br><br>        });<br>        add(btn, BorderLayout.SOUTH);<br><br>        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br>        pack();<br><br>        t = new Timer(INTERVAL, this);<br>        t.setRepeats(false);<br>    }<br><br>    @Override<br>    public void actionPerformed(ActionEvent e) {<br>        this.toFront();<br>        btn.setText("TEST " + (++counter));<br>        this.toBack();<br>        if (counter < MAX_COUNT) {<br>            enableTimer(true);<br>        } else {<br>            setVisible(false);<br>        }<br>    }<br><br>    void enableTimer(boolean enable) {<br>        if (enable) {<br>            t.start();<br>        } else {<br>            t.stop();<br>        }<br>    }<br><br>    int getCounter() {<br>        return counter;<br>    }<br>}</span><br></div><div><br></div><div>I will attach it in the JBS bug.</div><div><br></div><div>Regards,</div><div>Laurent</div></div></div></div></div>