8005629: javac warnings compiling java.awt.EventDispatchThread and sun.awt.X11.XIconWindow
Removed macosx specific workaround from shared code and made macosx use public API Reviewed-by: art, serb
This commit is contained in:
parent
42b8720bef
commit
959ddfce4a
@ -30,6 +30,8 @@ import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.print.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.print.*;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
@ -47,6 +49,8 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
private static String sShouldNotReachHere = "Should not reach here.";
|
||||
|
||||
private volatile SecondaryLoop printingLoop;
|
||||
|
||||
private boolean noDefaultPrinter = false;
|
||||
|
||||
private static Font defaultFont;
|
||||
@ -160,11 +164,22 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
volatile boolean onEventThread;
|
||||
|
||||
@Override
|
||||
protected void cancelDoc() throws PrinterAbortException {
|
||||
super.cancelDoc();
|
||||
if (printingLoop != null) {
|
||||
printingLoop.exit();
|
||||
}
|
||||
}
|
||||
|
||||
private void completePrintLoop() {
|
||||
Runnable r = new Runnable() { public void run() {
|
||||
synchronized(this) {
|
||||
performingPrinting = false;
|
||||
}
|
||||
if (printingLoop != null) {
|
||||
printingLoop.exit();
|
||||
}
|
||||
}};
|
||||
|
||||
if (onEventThread) {
|
||||
@ -219,17 +234,21 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
onEventThread = true;
|
||||
|
||||
printingLoop = AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>() {
|
||||
@Override
|
||||
public SecondaryLoop run() {
|
||||
return Toolkit.getDefaultToolkit()
|
||||
.getSystemEventQueue()
|
||||
.createSecondaryLoop();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// 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();
|
||||
@ -253,6 +272,9 @@ public class CPrinterJob extends RasterPrinterJob {
|
||||
performingPrinting = false;
|
||||
notify();
|
||||
}
|
||||
if (printingLoop != null) {
|
||||
printingLoop.exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize the collated, # copies, numPages, first/last pages. Need to
|
||||
|
@ -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();
|
||||
}
|
@ -383,31 +383,6 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
@ -107,34 +107,6 @@ class EventDispatchThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class XIconWindow extends XBaseWindow {
|
||||
}
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user