1898N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1898N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1898N/A *
1898N/A * This code is free software; you can redistribute it and/or modify it
1898N/A * under the terms of the GNU General Public License version 2 only, as
1898N/A * published by the Free Software Foundation.
1898N/A *
1898N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1898N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1898N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1898N/A * version 2 for more details (a copy is included in the LICENSE file that
1898N/A * accompanied this code).
1898N/A *
1898N/A * You should have received a copy of the GNU General Public License version
1898N/A * 2 along with this work; if not, write to the Free Software Foundation,
1898N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1898N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1898N/A */
1898N/A
1898N/A/*
1898N/A @test
1898N/A @bug 6852111
1898N/A @summary Unhandled 'spurious wakeup' in java.awt.EventQueue.invokeAndWait()
1898N/A @author dmitry.cherepanov@sun.com: area=awt.event
1898N/A @run main InvocationEventTest
1898N/A*/
1898N/A
1898N/A/**
1898N/A * InvocationEventTest.java
1898N/A *
1898N/A * summary: Tests new isDispatched method of the InvocationEvent class
1898N/A */
1898N/A
1898N/Aimport java.awt.*;
1898N/Aimport java.awt.event.*;
1898N/A
1898N/Apublic class InvocationEventTest
1898N/A{
1898N/A public static void main(String []s) throws Exception
1898N/A {
1898N/A Toolkit tk = Toolkit.getDefaultToolkit();
1898N/A Runnable runnable = new Runnable() {
1898N/A public void run() {
1898N/A }
1898N/A };
1898N/A Object lock = new Object();
1898N/A InvocationEvent event = new InvocationEvent(tk, runnable, lock, true);
1898N/A
1898N/A if (event.isDispatched()) {
1898N/A throw new RuntimeException(" Initially, the event shouldn't be dispatched ");
1898N/A }
1898N/A
1898N/A synchronized(lock) {
1898N/A tk.getSystemEventQueue().postEvent(event);
1898N/A while(!event.isDispatched()) {
1898N/A lock.wait();
1898N/A }
1898N/A }
1898N/A
1898N/A if(!event.isDispatched()) {
1898N/A throw new RuntimeException(" Finally, the event should be dispatched ");
1898N/A }
1898N/A }
1898N/A}