# HG changeset patch # User serb # Date 1342813990 -14400 # Node ID bf941141d1bf029ab47394dfe0643216bc531085 # Parent 84d5cdbe7bce2caf907ec842ac7b4fa2097fb295 7184401: JDk7u6 : Missing main menu bar in Netbeans after fix for 7162144 Reviewed-by: prr, art diff -r 84d5cdbe7bce -r bf941141d1bf src/share/classes/java/awt/EventQueue.java --- a/src/share/classes/java/awt/EventQueue.java Fri Jul 20 10:17:33 2012 -0700 +++ b/src/share/classes/java/awt/EventQueue.java Fri Jul 20 23:53:10 2012 +0400 @@ -41,12 +41,11 @@ import sun.util.logging.PlatformLogger; import sun.awt.AppContext; -import sun.awt.AWTAccessor; import sun.awt.AWTAutoShutdown; -import sun.awt.AWTInterruptedException; import sun.awt.PeerEvent; import sun.awt.SunToolkit; import sun.awt.EventQueueItem; +import sun.awt.AWTAccessor; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; @@ -1049,17 +1048,15 @@ pushPopLock.lock(); try { if (edt == dispatchThread) { - if (peekEvent() != null || !SunToolkit.isPostEventQueueEmpty()) { - if (!forceDetach) { - /* - * Fix for 4648733. Check both the associated java event - * queue and the PostEventQueue. - */ - return false; - } else { - // 7162144 - derail pending events - removeAllEvents(); - } + /* + * Don't detach the thread if any events are pending. Not + * sure if it's a possible scenario, though. + * + * Fix for 4648733. Check both the associated java event + * queue and the PostEventQueue. + */ + if (!forceDetach && (peekEvent() != null) || !SunToolkit.isPostEventQueueEmpty()) { + return false; } dispatchThread = null; } @@ -1141,39 +1138,6 @@ } } - private void removeAllEvents() { - SunToolkit.flushPendingEvents(); - pushPopLock.lock(); - try { - for (int i = 0; i < NUM_PRIORITIES; i++) { - EventQueueItem entry = queues[i].head; - EventQueueItem prev = null; - while (entry != null) { - if (entry.event instanceof InvocationEvent) { - AWTAccessor.getInvocationEventAccessor(). - dispose((InvocationEvent)entry.event); - } - if (entry.event instanceof SequencedEvent) { - ((SequencedEvent)entry.event).dispose(); - } - if (entry.event instanceof SentEvent) { - ((SentEvent)entry.event).dispose(); - } - if (prev == null) { - queues[i].head = entry.next; - } else { - prev.next = entry.next; - } - uncacheEQItem(entry); - entry = entry.next; - } - queues[i].tail = prev; - } - } finally { - pushPopLock.unlock(); - } - } - static void setCurrentEventAndMostRecentTime(AWTEvent e) { Toolkit.getEventQueue().setCurrentEventAndMostRecentTimeImpl(e); } @@ -1281,11 +1245,7 @@ Throwable eventThrowable = event.getThrowable(); if (eventThrowable != null) { - if (eventThrowable instanceof AWTInterruptedException) { - throw new InterruptedException(eventThrowable.getMessage()); - } else { - throw new InvocationTargetException(eventThrowable); - } + throw new InvocationTargetException(eventThrowable); } } diff -r 84d5cdbe7bce -r bf941141d1bf src/share/classes/java/awt/event/InvocationEvent.java --- a/src/share/classes/java/awt/event/InvocationEvent.java Fri Jul 20 10:17:33 2012 -0700 +++ b/src/share/classes/java/awt/event/InvocationEvent.java Fri Jul 20 23:53:10 2012 +0400 @@ -28,9 +28,6 @@ import java.awt.ActiveEvent; import java.awt.AWTEvent; -import sun.awt.AWTAccessor; -import sun.awt.AWTInterruptedException; - /** * An event which executes the run() method on a Runnable * when dispatched by the AWT event dispatcher thread. This class can @@ -130,16 +127,6 @@ */ private static final long serialVersionUID = 436056344909459450L; - static { - AWTAccessor.setInvocationEventAccessor( - new AWTAccessor.InvocationEventAccessor() { - @Override - public void dispose(InvocationEvent ie) { - ie.dispose(); - } - }); - } - /** * Constructs an InvocationEvent with the specified * source which will execute the runnable's run @@ -241,19 +228,6 @@ this.when = System.currentTimeMillis(); } - /* - * Marks the event as dispatched and notifies all interested parties. - */ - private void setDispatched() { - dispatched = true; - - if (notifier != null) { - synchronized (notifier) { - notifier.notifyAll(); - } - } - } - /** * Executes the Runnable's run() method and notifies the * notifier (if any) when run() has returned or thrown an exception. @@ -277,16 +251,14 @@ runnable.run(); } } finally { - setDispatched(); - } - } + dispatched = true; - private void dispose() { - throwable = exception = - new AWTInterruptedException( - "The event is discarded due to Event Thread interruption"); - - setDispatched(); + if (notifier != null) { + synchronized (notifier) { + notifier.notifyAll(); + } + } + } } /** diff -r 84d5cdbe7bce -r bf941141d1bf src/share/classes/sun/awt/AWTAccessor.java --- a/src/share/classes/sun/awt/AWTAccessor.java Fri Jul 20 10:17:33 2012 -0700 +++ b/src/share/classes/sun/awt/AWTAccessor.java Fri Jul 20 23:53:10 2012 +0400 @@ -27,7 +27,7 @@ import java.awt.*; import java.awt.KeyboardFocusManager; -import java.awt.event.*; +import java.awt.event.InputEvent; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; @@ -478,16 +478,6 @@ boolean isMultipleMode(FileDialog fileDialog); } - /** - * An accessor for the InvocationEvent class - */ - public interface InvocationEventAccessor { - /** - * Dispose an InvocationEvent (cancel it). - */ - void dispose(InvocationEvent ie); - } - /* * Accessor instances are initialized in the static initializers of * corresponding AWT classes by using setters defined below. @@ -503,7 +493,6 @@ private static EventQueueAccessor eventQueueAccessor; private static PopupMenuAccessor popupMenuAccessor; private static FileDialogAccessor fileDialogAccessor; - private static InvocationEventAccessor invocationEventAccessor; /* * Set an accessor object for the java.awt.Component class. @@ -694,21 +683,4 @@ return fileDialogAccessor; } - /** - * Set an accessor object for the java.awt.event.InvocationEvent class. - */ - public static void setInvocationEventAccessor(InvocationEventAccessor iea) { - invocationEventAccessor = iea; - } - - /** - * Retrieve the accessor object for the java.awt.event.InvocationEvent class. - */ - public static InvocationEventAccessor getInvocationEventAccessor() { - if (invocationEventAccessor == null) { - unsafe.ensureClassInitialized(InvocationEvent.class); - } - return invocationEventAccessor; - } - } diff -r 84d5cdbe7bce -r bf941141d1bf src/share/classes/sun/awt/AWTInterruptedException.java --- a/src/share/classes/sun/awt/AWTInterruptedException.java Fri Jul 20 10:17:33 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.awt; - -/** - * A utility exception class used to eliminate package borders between the - * EventQueue and the InvocationEvent classes. - */ -public class AWTInterruptedException extends Exception { - public AWTInterruptedException(String msg) { - super(msg); - } -}