--- old/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2013-01-24 20:09:25.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2013-01-24 20:09:25.000000000 +0400 @@ -47,6 +47,10 @@ private static String sShouldNotReachHere = "Should not reach here."; + private final SecondaryLoop printingLoop = Toolkit.getDefaultToolkit() + .getSystemEventQueue() + .createSecondaryLoop(); + private boolean noDefaultPrinter = false; private static Font defaultFont; @@ -160,11 +164,24 @@ volatile boolean onEventThread; + @Override + public void cancel() { + super.cancel(); + printingLoop.exit(); + } + + @Override + protected void cancelDoc() throws PrinterAbortException { + super.cancelDoc(); + printingLoop.exit(); + } + private void completePrintLoop() { Runnable r = new Runnable() { public void run() { synchronized(this) { performingPrinting = false; } + printingLoop.exit(); }}; if (onEventThread) { @@ -223,13 +240,8 @@ // Fire off the print rendering loop on the AppKit thread, and don't have // it wait and block this thread. if (printLoop(false, firstPage, lastPage)) { - // Fire off the EventConditional that will what until the condition is met, - // but will still process AWTEvent's as they occur. - new EventDispatchAccess() { - public boolean evaluate() { - return performingPrinting; - } - }.pumpEventsAndWait(); + // Start a secondary loop on EDT until printing operation is finished or cancelled + printingLoop.enter(); } } catch (Exception e) { e.printStackTrace(); @@ -251,6 +263,7 @@ // NOTE: Native code shouldn't allow exceptions out while // printing. They should cancel the print loop. performingPrinting = false; + printingLoop.exit(); notify(); } } --- old/src/macosx/native/sun/awt/CPrinterJob.m 2013-01-24 20:09:26.000000000 +0400 +++ new/src/macosx/native/sun/awt/CPrinterJob.m 2013-01-24 20:09:26.000000000 +0400 @@ -384,31 +384,6 @@ } /* - * Class: sun_lwawt_macosx_EventDispatchAccess - * Method: pumpEventsAndWait - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_EventDispatchAccess_pumpEventsAndWait -(JNIEnv *env, jobject eda) -{ - static JNF_CLASS_CACHE(jc_Thread, "java/lang/Thread"); - static JNF_STATIC_MEMBER_CACHE(jm_currentThread, jc_Thread, "currentThread", "()Ljava/lang/Thread;"); - static JNF_CLASS_CACHE(jc_EventDispatchThread, "java/awt/EventDispatchThread"); - static JNF_MEMBER_CACHE(jm_macosxGetConditional, jc_EventDispatchThread, "_macosxGetConditional", "(Ljava/lang/Object;)Ljava/awt/Conditional;"); - static JNF_MEMBER_CACHE(jm_pumpEvents, jc_EventDispatchThread, "pumpEvents", "(Ljava/awt/Conditional;)V"); - -JNF_COCOA_DURING(env); - - jobject thread = JNFCallStaticObjectMethod(env, jm_currentThread); - jobject conditional = JNFCallObjectMethod(env, thread, jm_macosxGetConditional, eda); - if (conditional != NULL) { - JNFCallVoidMethod(env, thread, jm_pumpEvents, conditional); - } - -JNF_COCOA_HANDLE(env); -} - -/* * Class: sun_lwawt_macosx_CPrinterJob * Method: abortDoc * Signature: ()V --- old/src/share/classes/java/awt/EventDispatchThread.java 2013-01-24 20:09:27.000000000 +0400 +++ new/src/share/classes/java/awt/EventDispatchThread.java 2013-01-24 20:09:27.000000000 +0400 @@ -107,34 +107,6 @@ } } - // MacOSX change: - // This was added because this class (and java.awt.Conditional) are package private. - // There are certain instances where classes in other packages need to block the - // AWTEventQueue while still allowing it to process events. This uses reflection - // to call back into the caller in order to remove dependencies. - // - // NOTE: This uses reflection in its implementation, so it is not for performance critical code. - // - // cond is an instance of sun.lwawt.macosx.EventDispatchAccess - // - private Conditional _macosxGetConditional(final Object cond) { - try { - return new Conditional() { - final Method evaluateMethod = Class.forName("sun.lwawt.macosx.EventDispatchAccess").getMethod("evaluate", null); - public boolean evaluate() { - try { - return ((Boolean)evaluateMethod.invoke(cond, null)).booleanValue(); - } catch (Exception e) { - return false; - } - } - }; - } catch (Exception e) { - return new Conditional() { public boolean evaluate() { return false; } }; - } - } - - void pumpEvents(Conditional cond) { pumpEvents(ANY_EVENT, cond); } --- old/src/solaris/classes/sun/awt/X11/XIconWindow.java 2013-01-24 20:09:28.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XIconWindow.java 2013-01-24 20:09:27.000000000 +0400 @@ -92,7 +92,7 @@ } XIconSize[] sizeList = getIconSizes(); - log.finest("Icon sizes: {0}", sizeList); + log.finest("Icon sizes: {0}", (Object[]) sizeList); if (sizeList == null) { // No icon sizes so we simply fall back to 16x16 return new Dimension(16, 16); --- old/src/macosx/classes/sun/lwawt/macosx/EventDispatchAccess.java 2013-01-24 20:09:28.000000000 +0400 +++ /dev/null 2013-01-24 20:09:28.000000000 +0400 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011, 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.lwawt.macosx; - -// This exists strictly to work around the fact that java.awt.Conditional isn't a public class. -// It uses java reflection to get the EventDispatchThread class and call a MacOSX only -// method on it. -// -// NOTE: This uses reflection in its implementation, so it is not for performance critical code. -// -// See java.awt.EventDispatchThread and apple.awt.CPrintJob for more. -// -public abstract class EventDispatchAccess { - public native void pumpEventsAndWait(); - public abstract boolean evaluate(); -}