--- old/src/share/classes/java/awt/Component.java 2014-06-26 13:03:42.000000000 +0400 +++ new/src/share/classes/java/awt/Component.java 2014-06-26 13:03:41.000000000 +0400 @@ -67,7 +67,6 @@ import sun.awt.ConstrainableGraphics; import sun.awt.SubRegionShowable; import sun.awt.SunToolkit; -import sun.awt.WindowClosingListener; import sun.awt.CausedFocusEvent; import sun.awt.EmbeddedFrame; import sun.awt.dnd.SunDropTargetEvent; @@ -544,8 +543,6 @@ transient MouseWheelListener mouseWheelListener; transient InputMethodListener inputMethodListener; - transient RuntimeException windowClosingException = null; - /** Internal, constants for serialization */ final static String actionListenerK = "actionL"; final static String adjustmentListenerK = "adjustmentL"; @@ -4866,16 +4863,6 @@ } break; - case WindowEvent.WINDOW_CLOSING: - if (toolkit instanceof WindowClosingListener) { - windowClosingException = ((WindowClosingListener) - toolkit).windowClosingNotify((WindowEvent)e); - if (checkWindowClosingException()) { - return; - } - } - break; - default: break; } @@ -4931,21 +4918,6 @@ } /* - * 8. Special handling for 4061116 : Hook for browser to close modal - * dialogs. - */ - if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) { - if (toolkit instanceof WindowClosingListener) { - windowClosingException = - ((WindowClosingListener)toolkit). - windowClosingDelivered((WindowEvent)e); - if (checkWindowClosingException()) { - return; - } - } - } - - /* * 9. Allow the peer to process the event. * Except KeyEvents, they will be processed by peer after * all KeyEventPostProcessors @@ -5052,20 +5024,6 @@ return false; } - boolean checkWindowClosingException() { - if (windowClosingException != null) { - if (this instanceof Dialog) { - ((Dialog)this).interruptBlocking(); - } else { - windowClosingException.fillInStackTrace(); - windowClosingException.printStackTrace(); - windowClosingException = null; - } - return true; - } - return false; - } - boolean areInputMethodsEnabled() { // in 1.2, we assume input method support is required for all // components that handle key events, but components can turn off --- old/src/share/classes/java/awt/Container.java 2014-06-26 13:03:43.000000000 +0400 +++ new/src/share/classes/java/awt/Container.java 2014-06-26 13:03:43.000000000 +0400 @@ -2899,17 +2899,10 @@ } } - Runnable pumpEventsForHierarchy = new Runnable() { - public void run() { - EventDispatchThread dispatchThread = - (EventDispatchThread)Thread.currentThread(); - dispatchThread.pumpEventsForHierarchy( - new Conditional() { - public boolean evaluate() { - return ((windowClosingException == null) && (nativeContainer.modalComp != null)) ; - } - }, Container.this); - } + Runnable pumpEventsForHierarchy = () -> { + EventDispatchThread dispatchThread = (EventDispatchThread)Thread.currentThread(); + dispatchThread.pumpEventsForHierarchy(() -> nativeContainer.modalComp != null, + Container.this); }; if (EventQueue.isDispatchThread()) { @@ -2927,8 +2920,7 @@ postEvent(new PeerEvent(this, pumpEventsForHierarchy, PeerEvent.PRIORITY_EVENT)); - while ((windowClosingException == null) && - (nativeContainer.modalComp != null)) + while (nativeContainer.modalComp != null) { try { getTreeLock().wait(); @@ -2938,10 +2930,6 @@ } } } - if (windowClosingException != null) { - windowClosingException.fillInStackTrace(); - throw windowClosingException; - } if (predictedFocusOwner != null) { KeyboardFocusManager.getCurrentKeyboardFocusManager(). dequeueKeyEvents(time, predictedFocusOwner); --- old/src/share/classes/java/awt/Dialog.java 2014-06-26 13:03:44.000000000 +0400 +++ new/src/share/classes/java/awt/Dialog.java 2014-06-26 13:03:44.000000000 +0400 @@ -40,6 +40,7 @@ import sun.awt.util.IdentityArrayList; import sun.awt.util.IdentityLinkedList; import java.security.AccessControlException; +import java.util.function.BooleanSupplier; /** * A Dialog is a top-level window with a title and a border @@ -1044,13 +1045,6 @@ predictedFocusOwner = getMostRecentFocusOwner(); if (conditionalShow(predictedFocusOwner, time)) { modalFilter = ModalEventFilter.createFilterForDialog(this); - final Conditional cond = new Conditional() { - @Override - public boolean evaluate() { - return windowClosingException == null; - } - }; - // if this dialog is toolkit-modal, the filter should be added // to all EDTs (for all AppContexts) if (modalityType == ModalityType.TOOLKIT_MODAL) { @@ -1063,10 +1057,7 @@ EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY); // it may occur that EDT for appContext hasn't been started yet, so // we post an empty invocation event to trigger EDT initialization - Runnable createEDT = new Runnable() { - public void run() {}; - }; - eventQueue.postEvent(new InvocationEvent(this, createEDT)); + eventQueue.postEvent(new InvocationEvent(this, () -> {})); EventDispatchThread edt = eventQueue.getDispatchThread(); edt.addEventFilter(modalFilter); } @@ -1075,12 +1066,8 @@ modalityPushed(); try { final EventQueue eventQueue = AccessController.doPrivileged( - new PrivilegedAction() { - public EventQueue run() { - return Toolkit.getDefaultToolkit().getSystemEventQueue(); - } - }); - secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0); + (PrivilegedAction) Toolkit.getDefaultToolkit()::getSystemEventQueue); + secondaryLoop = eventQueue.createSecondaryLoop(() -> true, modalFilter, 0); if (!secondaryLoop.enter()) { secondaryLoop = null; } @@ -1102,11 +1089,6 @@ edt.removeEventFilter(modalFilter); } } - - if (windowClosingException != null) { - windowClosingException.fillInStackTrace(); - throw windowClosingException; - } } } finally { if (predictedFocusOwner != null) { @@ -1134,16 +1116,6 @@ } } - void interruptBlocking() { - if (isModal()) { - disposeImpl(); - } else if (windowClosingException != null) { - windowClosingException.fillInStackTrace(); - windowClosingException.printStackTrace(); - windowClosingException = null; - } - } - private void hideAndDisposePreHandler() { isInHide = true; synchronized (getTreeLock()) { --- old/src/share/classes/sun/awt/SunToolkit.java 2014-06-26 13:03:45.000000000 +0400 +++ new/src/share/classes/sun/awt/SunToolkit.java 2014-06-26 13:03:45.000000000 +0400 @@ -59,8 +59,7 @@ import java.security.AccessController; public abstract class SunToolkit extends Toolkit - implements WindowClosingSupport, WindowClosingListener, - ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider { + implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider { // 8014718: logging has been removed from SunToolkit @@ -1201,42 +1200,6 @@ return getStartupLocale(); } - // Support for window closing event notifications - private transient WindowClosingListener windowClosingListener = null; - /** - * @see sun.awt.WindowClosingSupport#getWindowClosingListener - */ - public WindowClosingListener getWindowClosingListener() { - return windowClosingListener; - } - /** - * @see sun.awt.WindowClosingSupport#setWindowClosingListener - */ - public void setWindowClosingListener(WindowClosingListener wcl) { - windowClosingListener = wcl; - } - - /** - * @see sun.awt.WindowClosingListener#windowClosingNotify - */ - public RuntimeException windowClosingNotify(WindowEvent event) { - if (windowClosingListener != null) { - return windowClosingListener.windowClosingNotify(event); - } else { - return null; - } - } - /** - * @see sun.awt.WindowClosingListener#windowClosingDelivered - */ - public RuntimeException windowClosingDelivered(WindowEvent event) { - if (windowClosingListener != null) { - return windowClosingListener.windowClosingDelivered(event); - } else { - return null; - } - } - private static DefaultMouseInfoPeer mPeer = null; protected synchronized MouseInfoPeer getMouseInfoPeer() { --- old/src/share/classes/sun/awt/WindowClosingListener.java 2014-06-26 13:03:47.000000000 +0400 +++ /dev/null 2014-06-26 13:03:47.000000000 +0400 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 1999, 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; - -import java.awt.event.WindowEvent; - -/** - * Interface for listening to WINDOW_CLOSING events before and - * after they are posted to the queue. - */ -public interface WindowClosingListener { - /** - * Called before a WINDOW_CLOSING event gets posted to the queue. - * @param event The WINDOW_CLOSING event that will be posted. - * @return A RuntimeException if the result of this function - * call needs to interrupt a blocking thread. The exception - * returned will be thrown from that thread. This function - * should return null otherwise. - */ - RuntimeException windowClosingNotify(WindowEvent event); - /** - * Called after a WINDOW_CLOSING event gets posted to the queue. - * @param event The WINDOW_CLOSING event that has been posted. - * @return A RuntimeException if the result of this function - * call needs to interrupt a blocking thread. The exception - * returned will be thrown from that thread. This function - * should return null otherwise. - */ - RuntimeException windowClosingDelivered(WindowEvent event); -} --- old/src/share/classes/sun/awt/WindowClosingSupport.java 2014-06-26 13:03:47.000000000 +0400 +++ /dev/null 2014-06-26 13:03:47.000000000 +0400 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1999, 2007, 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; - -/** - * Interface for identifying and casting toolkits that support - * WindowClosingListeners. - */ -public interface WindowClosingSupport { - WindowClosingListener getWindowClosingListener(); - void setWindowClosingListener(WindowClosingListener wcl); -}