提交 ee769824 编写于 作者: A art

6678385: Random java.lang.StackOverflowError from various JDKs

Reviewed-by: stayer
上级 59c9557c
......@@ -128,6 +128,7 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler;
Java_sun_awt_X11_XlibWrapper_XSetErrorHandler;
Java_sun_awt_X11_XlibWrapper_CallErrorHandler;
Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent;
Java_sun_awt_X11_XlibWrapper_XInternAtoms;
Java_sun_awt_X11_XlibWrapper_XChangeWindowAttributes;
Java_sun_awt_X11_XlibWrapper_XDeleteProperty;
......@@ -276,7 +277,6 @@ SUNWprivate_1.1 {
Java_sun_awt_X11_XToolkit_getDefaultXColormap;
Java_sun_awt_X11_XToolkit_getDefaultScreenData;
Java_sun_awt_X11_XToolkit_getEnv;
Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler;
Java_sun_awt_X11_XlibWrapper_XCreateBitmapFromData;
Java_sun_awt_X11_XlibWrapper_XFreePixmap;
Java_sun_awt_X11_XlibWrapper_XAllocColor;
......
......@@ -120,7 +120,7 @@ class MotifDnDConstants {
false,
XConstants.AnyPropertyType);
try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg.getData() != 0 &&
......@@ -190,7 +190,7 @@ class MotifDnDConstants {
try {
Native.putLong(data, motifWindow);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
defaultRootWindow,
XA_MOTIF_DRAG_WINDOW.getAtom(),
......@@ -280,7 +280,7 @@ class MotifDnDConstants {
false,
XA_MOTIF_DRAG_TARGETS.getAtom());
try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success
|| wpg.getActualType() != XA_MOTIF_DRAG_TARGETS.getAtom()
......@@ -394,7 +394,7 @@ class MotifDnDConstants {
}
}
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
motifWindow,
XA_MOTIF_DRAG_TARGETS.getAtom(),
......@@ -410,7 +410,7 @@ class MotifDnDConstants {
// Create a new motif window and retry.
motifWindow = createMotifWindow();
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(),
motifWindow,
XA_MOTIF_DRAG_TARGETS.getAtom(),
......@@ -534,7 +534,7 @@ class MotifDnDConstants {
// CARD32 icc_handle
unsafe.putInt(structData + 4, (int)XA_MOTIF_ATOM_0.getAtom());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
XA_MOTIF_ATOM_0.getAtom(),
XA_MOTIF_DRAG_INITIATOR_INFO.getAtom(),
......@@ -567,7 +567,7 @@ class MotifDnDConstants {
unsafe.putShort(data + 10, (short)0); /* pad */
unsafe.putInt(data + 12, dataSize);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), window,
XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
......
......@@ -184,7 +184,7 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol
XConstants.AnyPropertyType);
try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
......
......@@ -102,7 +102,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
......@@ -162,7 +162,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
unsafe.putInt(data + 12, dataSize);
}
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
......@@ -204,7 +204,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
......@@ -236,7 +236,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
unsafe.putInt(data + 4, tproxy);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangeProperty(XToolkit.getDisplay(), embedder,
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
MotifDnDConstants.XA_MOTIF_DRAG_RECEIVER_INFO.getAtom(),
......@@ -276,7 +276,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
......@@ -325,7 +325,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == (int)XConstants.Success && wpg.getData() != 0 &&
wpg.getActualType() != 0 && wpg.getActualFormat() == 8 &&
......@@ -375,7 +375,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
MotifDnDConstants.XA_MOTIF_DRAG_INITIATOR_INFO.getAtom());
try {
int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success && wpg.getData() != 0 &&
wpg.getActualType() ==
......@@ -412,7 +412,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
*/
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
source_win, wattr.pData);
......@@ -429,7 +429,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
wattr.dispose();
}
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
source_win_mask |
XConstants.StructureNotifyMask);
......@@ -1020,7 +1020,7 @@ class MotifDnDDropTargetProtocol extends XDropTargetProtocol {
if (sourceWindow != 0) {
XToolkit.awtLock();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
sourceWindowMask);
XToolkit.RESTORE_XERROR_HANDLER();
......
......@@ -75,7 +75,7 @@ public class WindowPropertyGetter {
public int execute() {
return execute(null);
}
public int execute(XToolkit.XErrorHandler errorHandler) {
public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
......@@ -94,7 +94,7 @@ public class WindowPropertyGetter {
// Fix for performance problem - IgnodeBadWindowHandler is
// used too much without reason, just ignore it
if (errorHandler == XToolkit.IgnoreBadWindowHandler) {
if (errorHandler instanceof XErrorHandler.IgnoreBadWindowHandler) {
errorHandler = null;
}
......
......@@ -126,7 +126,7 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,
false, xSettingsPropertyAtom.getAtom() );
try {
int status = getter.execute(XToolkit.IgnoreBadWindowHandler);
int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter.getData() == 0) {
if (log.isLoggable(Level.FINE)) log.fine("OH OH : getter failed status = " + status );
......
......@@ -1100,7 +1100,8 @@ abstract class XDecoratedPeer extends XWindowPeer {
}
boolean isOverrideRedirect() {
return false;
// return false;
return ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target);
}
public boolean requestWindowFocus(long time, boolean timeProvided) {
......
......@@ -96,7 +96,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
action_count++;
}
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndActionList.setAtomData(window,
XAtom.XA_ATOM,
data, action_count);
......@@ -117,7 +117,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
try {
Native.put(data, formats);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndTypeList.setAtomData(window,
XAtom.XA_ATOM,
data, formats.length);
......@@ -195,7 +195,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
new WindowPropertyGetter(window, XDnDConstants.XA_XdndAware, 0, 1,
false, XConstants.AnyPropertyType);
int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
......@@ -215,7 +215,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg2.getData() != 0 &&
......@@ -233,7 +233,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg3.getData() == 0 ||
......@@ -249,7 +249,7 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
XConstants.AnyPropertyType);
try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg4.getData() == 0 ||
......
......@@ -88,7 +88,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
try {
Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(window, XAtom.XA_ATOM, data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -122,7 +122,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType);
try {
status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
......@@ -141,7 +141,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg2.getData() != 0 &&
......@@ -159,7 +159,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg3.getData() == 0 ||
......@@ -175,7 +175,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg4.getData() == 0 ||
......@@ -205,7 +205,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
/* The proxy window must have the XdndAware set, as XDnD protocol
prescribes to check the proxy window for XdndAware. */
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(newProxy, XAtom.XA_ATOM,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -219,7 +219,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, newProxy);
/* The proxy window must have the XdndProxy set to point to itself.*/
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(newProxy, XAtom.XA_WINDOW,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -232,7 +232,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, XDnDConstants.XDND_PROTOCOL_VERSION);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -245,7 +245,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, newProxy);
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -278,7 +278,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
try {
Native.putLong(data, 0, entry.getVersion());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndAware.setAtomData(embedder, XAtom.XA_ATOM,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -291,7 +291,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
Native.putLong(data, 0, (int)entry.getProxy());
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndProxy.setAtomData(embedder, XAtom.XA_WINDOW,
data, 1);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -329,7 +329,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType);
try {
status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
......@@ -348,7 +348,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg2.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg2.getData() != 0 &&
......@@ -366,7 +366,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 1, false, XAtom.XA_WINDOW);
try {
status = wpg3.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg3.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg3.getData() == 0 ||
......@@ -382,7 +382,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
XConstants.AnyPropertyType);
try {
status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg4.getData() == 0 ||
......@@ -411,7 +411,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
false, XConstants.AnyPropertyType);
try {
int status = wpg1.execute(XToolkit.IgnoreBadWindowHandler);
int status = wpg1.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status == XConstants.Success &&
wpg1.getData() != 0 && wpg1.getActualType() == XAtom.XA_ATOM) {
......@@ -473,7 +473,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false,
XAtom.XA_ATOM);
try {
wpg.execute(XToolkit.IgnoreBadWindowHandler);
wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) {
......@@ -505,7 +505,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false,
XAtom.XA_ATOM);
try {
wpg.execute(XToolkit.IgnoreBadWindowHandler);
wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) {
......@@ -541,7 +541,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
*/
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
source_win, wattr.pData);
......@@ -558,7 +558,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
wattr.dispose();
}
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), source_win,
source_win_mask |
XConstants.StructureNotifyMask);
......@@ -963,7 +963,7 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
if (sourceWindow != 0) {
XToolkit.awtLock();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), sourceWindow,
sourceWindowMask);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -1104,14 +1104,14 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
0, 0xFFFF, false,
XAtom.XA_ATOM);
try {
wpg.execute(XToolkit.IgnoreBadWindowHandler);
wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XAtom.XA_ATOM &&
wpg.getActualFormat() == 32) {
XToolkit.awtLock();
try {
XToolkit.WITH_XERROR_HANDLER(XWM.VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(),
XAtom.XA_ATOM,
wpg.getData(),
......
......@@ -181,7 +181,7 @@ abstract class XDragSourceProtocol {
long time) {
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
targetWindow, wattr.pData);
......@@ -198,7 +198,7 @@ abstract class XDragSourceProtocol {
wattr.dispose();
}
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
targetWindowMask |
XConstants.StructureNotifyMask);
......@@ -214,7 +214,7 @@ abstract class XDragSourceProtocol {
}
protected final void finalizeDrop() {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
targetWindowMask);
XToolkit.RESTORE_XERROR_HANDLER();
......
......@@ -168,7 +168,7 @@ final class XDropTargetRegistry {
if (dest_x >= 0 && dest_y >= 0) {
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
window, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -222,7 +222,7 @@ final class XDropTargetRegistry {
long event_mask = 0;
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
embedder, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -240,7 +240,7 @@ final class XDropTargetRegistry {
}
if ((event_mask & XConstants.PropertyChangeMask) == 0) {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
event_mask | XConstants.PropertyChangeMask);
XToolkit.RESTORE_XERROR_HANDLER();
......@@ -394,7 +394,7 @@ final class XDropTargetRegistry {
/* Restore the original event mask for the embedder. */
if ((event_mask & XConstants.PropertyChangeMask) == 0) {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
event_mask);
XToolkit.RESTORE_XERROR_HANDLER();
......
......@@ -301,7 +301,7 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener
try {
XWindowAttributes wattr = new XWindowAttributes();
try {
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
xembed.handle, wattr.pData);
......
/*
* Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.X11;
public abstract class XErrorHandler {
/*
* Called under AWT lock
*/
public abstract int handleError(long display, XErrorEvent err);
/*
* Forwards all the errors to saved error handler (which was
* set before XToolkit had been initialized).
*/
public static class XBaseErrorHandler extends XErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
/*
* Instead of validating window id, we simply call XGetWindowProperty,
* but temporary install this function as the error handler to ignore
* BadWindow error.
*/
public static class IgnoreBadWindowHandler extends XBaseErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
if (err.get_error_code() == XConstants.BadWindow) {
return 0;
}
return super.handleError(display, err);
}
// Shared instance
private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
public static IgnoreBadWindowHandler getInstance() {
return theInstance;
}
}
public static class VerifyChangePropertyHandler extends XBaseErrorHandler {
@Override
public int handleError(long display, XErrorEvent err) {
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
}
return super.handleError(display, err);
}
// Shared instance
private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
public static IgnoreBadWindowHandler getInstance() {
return theInstance;
}
}
}
......@@ -35,20 +35,6 @@ class XProtocol {
private Map<XAtom, XAtomList> atomToList = new HashMap<XAtom, XAtomList>();
private Map<XAtom, Long> atomToAnchor = new HashMap<XAtom, Long>();
/*
* Temporary error handler that ensures that we know if
* XChangeProperty succeeded or not.
*/
static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XToolkit.XERROR_SAVE(err);
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
};
volatile boolean firstCheck = true;
/*
* Check that that the list of protocols specified by WM in property
......
......@@ -52,7 +52,7 @@ public class XQueryTree {
public int execute() {
return execute(null);
}
public int execute(XToolkit.XErrorHandler errorHandler) {
public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
if (isDisposed()) {
......
......@@ -149,63 +149,78 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
setBackingStoreType();
}
m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ;
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
}
// Error handler stuff
static XErrorEvent saved_error;
static long saved_error_handler;
static XErrorHandler curErrorHandler;
// Should be called under LOCK, before releasing LOCK RESTORE_XERROR_HANDLER should be called
static void WITH_XERROR_HANDLER(XErrorHandler handler) {
//---- ERROR HANDLER CODE ----//
/*
* Error handler at the moment of XToolkit initialization
*/
private static long saved_error_handler;
/*
* XErrorEvent being handled
*/
static volatile XErrorEvent saved_error;
/*
* Current error handler or null if no error handler is set
*/
private static XErrorHandler current_error_handler;
/*
* Value of sun.awt.noisyerrorhandler system property
*/
private static boolean noisyAwtHandler;
public static void WITH_XERROR_HANDLER(XErrorHandler handler) {
saved_error = null;
curErrorHandler = handler;
XSync();
saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
}
static void XERROR_SAVE(XErrorEvent event) {
saved_error = event;
current_error_handler = handler;
}
// Should be called under LOCK
static void RESTORE_XERROR_HANDLER() {
XSync();
XlibWrapper.XSetErrorHandler(saved_error_handler);
curErrorHandler = null;
public static void RESTORE_XERROR_HANDLER() {
current_error_handler = null;
}
// Should be called under LOCK
static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
}
interface XErrorHandler {
int handleError(long display, XErrorEvent err);
public static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
if (saved_error_handler != 0) {
// Default XErrorHandler may just terminate the process. Don't call it.
// return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
}
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Unhandled XErrorEvent: " +
"id=" + error.get_resourceid() + ", " +
"serial=" + error.get_serial() + ", " +
"ec=" + error.get_error_code() + ", " +
"rc=" + error.get_request_code() + ", " +
"mc=" + error.get_minor_code());
}
return 0;
}
static int GlobalErrorHandler(long display, long event_ptr) {
// Called from the native code when an error occurs
private static int globalErrorHandler(long display, long event_ptr) {
if (noisyAwtHandler) {
XlibWrapper.PrintXErrorEvent(display, event_ptr);
}
XErrorEvent event = new XErrorEvent(event_ptr);
saved_error = event;
try {
if (curErrorHandler != null) {
return curErrorHandler.handleError(display, event);
if (current_error_handler != null) {
return current_error_handler.handleError(display, event);
} else {
return SAVED_ERROR_HANDLER(display, event);
}
} finally {
} catch (Throwable z) {
log.log(Level.FINE, "Error in GlobalErrorHandler", z);
}
return 0;
}
/*
* Instead of validating window id, we simply call XGetWindowProperty,
* but temporary install this function as the error handler to ignore
* BadWindow error.
*/
static XErrorHandler IgnoreBadWindowHandler = new XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XERROR_SAVE(err);
if (err.get_error_code() == XConstants.BadWindow) {
return 0;
} else {
return SAVED_ERROR_HANDLER(display, err);
}
}
};
//---- END OF ERROR HANDLER CODE ----//
private native static void initIDs();
native static void waitForEvents(long nextTaskTime);
......@@ -302,25 +317,34 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
} finally {
awtUnlock();
}
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
if (peer != null) {
peer.dispose();
}
if (xs != null) {
((XAWTXSettings)xs).dispose();
}
freeXKB();
if (log.isLoggable(Level.FINE)) {
dumpPeers();
}
public void run() {
XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
if (peer != null) {
peer.dispose();
}
});
if (xs != null) {
((XAWTXSettings)xs).dispose();
}
freeXKB();
if (log.isLoggable(Level.FINE)) {
dumpPeers();
}
awtLock();
try {
XlibWrapper.XSetErrorHandler(saved_error_handler);
} finally {
awtUnlock();
}
}
});
}
static String getCorrectXIDString(String val) {
......@@ -2409,8 +2433,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return new XDesktopPeer();
}
public static native void setNoisyXErrorHandler();
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
......
......@@ -57,7 +57,7 @@ public class XTranslateCoordinates {
public int execute() {
return execute(null);
}
public int execute(XToolkit.XErrorHandler errorHandler) {
public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
if (isDisposed()) {
......
......@@ -276,7 +276,7 @@ final class XWM
winmgr_running = false;
substruct.set_event_mask(XConstants.SubstructureRedirectMask);
XToolkit.WITH_XERROR_HANDLER(DetectWMHandler);
XToolkit.WITH_XERROR_HANDLER(detectWMHandler);
XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
XToolkit.getDefaultRootWindow(),
XConstants.CWEventMask,
......@@ -321,7 +321,7 @@ final class XWM
new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false,
XAtom.XA_STRING);
try {
int status = getter.execute(XToolkit.IgnoreBadWindowHandler);
int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter.getData() == 0) {
return 0;
}
......@@ -439,7 +439,7 @@ final class XWM
new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1,
false, XA_DT_SM_STATE_INFO);
try {
status = getter2.execute(XToolkit.IgnoreBadWindowHandler);
status = getter2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success || getter2.getData() == 0) {
......@@ -570,21 +570,6 @@ final class XWM
return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
}
/*
* Temporary error handler that ensures that we know if
* XChangeProperty succeeded or not.
*/
static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XToolkit.XERROR_SAVE(err);
if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
}
};
/*
* Prepare IceWM check.
*
......@@ -617,7 +602,7 @@ final class XWM
XToolkit.awtLock();
try {
XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
XA_ICEWM_WINOPTHINT.getAtom(),
XA_ICEWM_WINOPTHINT.getAtom(),
......@@ -682,20 +667,19 @@ final class XWM
* Temporary error handler that checks if selecting for
* SubstructureRedirect failed.
*/
static boolean winmgr_running = false;
static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() {
public int handleError(long display, XErrorEvent err) {
XToolkit.XERROR_SAVE(err);
if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes
&& err.get_error_code() == XConstants.BadAccess)
{
winmgr_running = true;
return 0;
} else {
return XToolkit.SAVED_ERROR_HANDLER(display, err);
}
private static boolean winmgr_running = false;
private static XErrorHandler detectWMHandler = new XErrorHandler.XBaseErrorHandler() {
@Override
public int handleError(long display, XErrorEvent err) {
if ((err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes) &&
(err.get_error_code() == XConstants.BadAccess))
{
winmgr_running = true;
return 0;
}
};
return super.handleError(display, err);
}
};
/*
* Make an educated guess about running window manager.
......
......@@ -149,7 +149,7 @@ public class XlibUtil
new XTranslateCoordinates(src, dst, p.x, p.y);
try
{
int status = xtc.execute(XToolkit.IgnoreBadWindowHandler);
int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if ((status != 0) &&
((XToolkit.saved_error == null) ||
(XToolkit.saved_error.get_error_code() == XConstants.Success)))
......@@ -306,7 +306,7 @@ public class XlibUtil
XWM.XA_WM_STATE);
try
{
wpg.execute(XToolkit.IgnoreBadWindowHandler);
wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (wpg.getActualType() == XWM.XA_WM_STATE.getAtom())
{
return true;
......@@ -345,7 +345,7 @@ public class XlibUtil
XWindowAttributes wattr = new XWindowAttributes();
try
{
XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
window, wattr.pData);
XToolkit.RESTORE_XERROR_HANDLER();
......
......@@ -646,4 +646,6 @@ static native String XSetLocaleModifiers(String modifier_list);
String javaVersion = XToolkit.getSystemProperty("java.version");
return javaVersion != null && javaVersion.contains("internal");
}
static native void PrintXErrorEvent(long display, long event_ptr);
}
......@@ -175,42 +175,11 @@ Java_sun_awt_X11GraphicsDevice_initIDs (JNIEnv *env, jclass cls)
}
#ifndef HEADLESS
/*
* error handlers
* XIOErrorHandler
*/
int
xerror_handler(Display * disp, XErrorEvent * err)
{
/* #ifdef DEBUG */
char msg[128];
char buf[128];
char *ev = getenv("NOISY_AWT");
if (!ev || !ev[0])
return 0;
XGetErrorText(disp, err->error_code, msg, sizeof(msg));
jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
XGetErrorDatabaseText(disp, "XRequest", buf, "Unknown", msg, sizeof(msg));
jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
if (err->request_code > 128) {
jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
}
if (awtLockInited) {
/*SignalError(lockedee->lastpc, lockedee, "fp/ade/gui/GUIException", msg); */
}
if (strcasecmp(ev, "abort") == 0) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
(*env)->FatalError(env, "xerror_handler abort");
}
/* #endif */
return 0;
}
static int
xioerror_handler(Display * disp)
static int xioerror_handler(Display *disp)
{
if (awtLockInited) {
if (errno == EPIPE) {
......@@ -886,7 +855,6 @@ awt_init_Display(JNIEnv *env, jobject this)
return NULL;
}
XSetErrorHandler(xerror_handler);
XSetIOErrorHandler(xioerror_handler);
/* set awt_numScreens, and whether or not we're using Xinerama */
......
......@@ -1458,7 +1458,6 @@ static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_dat
}
static void OpenXIMCallback(Display *display, XPointer client_data, XPointer call_data) {
extern int xerror_handler();
XIMCallback ximCallback;
X11im = XOpenIM(display, NULL, NULL, NULL);
......@@ -1469,13 +1468,6 @@ static void OpenXIMCallback(Display *display, XPointer client_data, XPointer cal
ximCallback.callback = (XIMProc)DestroyXIMCallback;
ximCallback.client_data = NULL;
XSetIMValues(X11im, XNDestroyCallback, &ximCallback, NULL);
/* Workaround for Solaris 2.6 bug 4097754. We're affected by this problem
* because Motif also calls XOpenIM for us. Re-registering the error handler
* that MToolkit has registered already after calling XOpenIM avoids the
* problem.
*/
XSetErrorHandler(xerror_handler);
}
static void DestroyXIMCallback(XIM im, XPointer client_data, XPointer call_data) {
......
......@@ -1926,26 +1926,6 @@ processOneEvent(XtInputMask iMask) {
XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent);
}
/*
** Bug #4361799: Forte4J sometimes crashes on Solaris:
** There is an underlying bug in Selection.c in Xt lib.
** The routine HandleSelectionEvents, can call EndProtectedSection()
** more than StartProtectedSection(), and then EndProtectedSection
** will restore the default XError handler. As a result awt's
** XError handler gets removed and we later crash on an XError.
**
** This happens when we call XtAppProcessEvent with event type 1e
** (SelectionRequest) when running two copies of Forte
**
** XSetErrorHandler can safely be called repeatedly, so we are
** fixing this with the sledgehammer, and resetting our XError
** handler every time through the loop:
*/
{
extern int32_t xerror_handler();
XSetErrorHandler(xerror_handler);
}
} /* processOneEvent() */
/*
......
......@@ -575,7 +575,6 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
pollFds[1].revents = 0;
}
AWT_NOFLUSH_UNLOCK();
/* ACTUALLY DO THE POLL() */
......@@ -684,8 +683,6 @@ JNIEXPORT jstring JNICALL Java_sun_awt_X11_XToolkit_getEnv
return ret;
}
static XErrorHandler saved_error_handler = NULL;
#ifdef __linux__
void print_stack(void)
{
......@@ -706,38 +703,6 @@ void print_stack(void)
}
#endif
static int NoisyXErrorHandler(Display * dpy, XErrorEvent * event) {
fprintf(stderr, "id=%x, serial=%x, ec=%d, rc=%d, mc=%d\n",
event->resourceid, event->serial, event->error_code,
event->request_code, event->minor_code);
/*
#ifdef __linux__
print_stack();
#endif
*/
if (jvm != NULL) {
JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
JNU_CallStaticMethodByName(env, NULL, "java/lang/Thread", "dumpStack", "()V");
}
if (!saved_error_handler) {
return saved_error_handler(dpy, event);
}
return 0;
}
/*
* Class: sun_awt_X11_XToolkit
* Method: setNoisyXErrorHandler
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XToolkit_setNoisyXErrorHandler
(JNIEnv *env , jclass clazz)
{
(*env)->GetJavaVM(env, &jvm);
saved_error_handler = XSetErrorHandler(NoisyXErrorHandler);
}
Window get_xawt_root_shell(JNIEnv *env) {
static jclass classXRootWindow = NULL;
static jmethodID methodGetXRootWindow = NULL;
......
......@@ -1186,7 +1186,7 @@ JavaVM* jvm = NULL;
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
if (jvm != NULL) {
JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "GlobalErrorHandler", "(JJ)I",
return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
} else {
return 0;
......@@ -1229,6 +1229,28 @@ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_CallErrorHandler
return (*(XErrorHandler)jlong_to_ptr(handler))((Display*) jlong_to_ptr(display), (XErrorEvent*) jlong_to_ptr(event_ptr));
}
/*
* Class: sun_awt_X11_XlibWrapper
* Method: PrintXErrorEvent
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XlibWrapper_PrintXErrorEvent
(JNIEnv *env, jclass clazz, jlong display, jlong event_ptr)
{
char msg[128];
char buf[128];
XErrorEvent* err = (XErrorEvent *)jlong_to_ptr(event_ptr);
XGetErrorText((Display *)jlong_to_ptr(display), err->error_code, msg, sizeof(msg));
jio_fprintf(stderr, "Xerror %s, XID %x, ser# %d\n", msg, err->resourceid, err->serial);
jio_snprintf(buf, sizeof(buf), "%d", err->request_code);
XGetErrorDatabaseText((Display *)jlong_to_ptr(display), "XRequest", buf, "Unknown", msg, sizeof(msg));
jio_fprintf(stderr, "Major opcode %d (%s)\n", err->request_code, msg);
if (err->request_code > 128) {
jio_fprintf(stderr, "Minor opcode %d\n", err->minor_code);
}
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册