6678385: Random java.lang.StackOverflowError from various JDKs
Reviewed-by: stayer
--- a/jdk/make/sun/xawt/mapfile-vers Wed May 06 20:06:23 2009 +0400
+++ b/jdk/make/sun/xawt/mapfile-vers Fri May 15 15:40:35 2009 +0400
@@ -128,6 +128,7 @@
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 @@
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;
--- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDConstants.java Fri May 15 15:40:35 2009 +0400
@@ -120,7 +120,7 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
// 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 @@
// 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 @@
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(),
--- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -184,7 +184,7 @@
XConstants.AnyPropertyType);
try {
- int status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
+ int status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
--- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDropTargetProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -102,7 +102,7 @@
XConstants.AnyPropertyType);
try {
- status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
+ status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
@@ -162,7 +162,7 @@
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 @@
XConstants.AnyPropertyType);
try {
- status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
+ status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
@@ -236,7 +236,7 @@
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 @@
XConstants.AnyPropertyType);
try {
- status = wpg.execute(XToolkit.IgnoreBadWindowHandler);
+ status = wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
/*
* DragICCI.h:
@@ -325,7 +325,7 @@
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 @@
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 @@
*/
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 @@
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 @@
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();
--- a/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/WindowPropertyGetter.java Fri May 15 15:40:35 2009 +0400
@@ -75,7 +75,7 @@
public int execute() {
return execute(null);
}
- public int execute(XToolkit.XErrorHandler errorHandler) {
+ public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
@@ -94,7 +94,7 @@
// 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;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Fri May 15 15:40:35 2009 +0400
@@ -126,7 +126,7 @@
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 );
--- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java Fri May 15 15:40:35 2009 +0400
@@ -1100,7 +1100,8 @@
}
boolean isOverrideRedirect() {
- return false;
+// return false;
+ return ((XToolkit)Toolkit.getDefaultToolkit()).isOverrideRedirect((Window)target);
}
public boolean requestWindowFocus(long time, boolean timeProvided) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -96,7 +96,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
XConstants.AnyPropertyType);
try {
- status = wpg4.execute(XToolkit.IgnoreBadWindowHandler);
+ status = wpg4.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
if (status != XConstants.Success ||
wpg4.getData() == 0 ||
--- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -88,7 +88,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
*/
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 @@
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 @@
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 @@
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(),
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -181,7 +181,7 @@
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 @@
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 @@
}
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();
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Fri May 15 15:40:35 2009 +0400
@@ -168,7 +168,7 @@
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 @@
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 @@
}
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 @@
/* 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();
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Fri May 15 15:40:35 2009 +0400
@@ -301,7 +301,7 @@
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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XErrorHandler.java Fri May 15 15:40:35 2009 +0400
@@ -0,0 +1,79 @@
+/*
+ * 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;
+ }
+ }
+}
--- a/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XProtocol.java Fri May 15 15:40:35 2009 +0400
@@ -35,20 +35,6 @@
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
--- a/jdk/src/solaris/classes/sun/awt/X11/XQueryTree.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XQueryTree.java Fri May 15 15:40:35 2009 +0400
@@ -52,7 +52,7 @@
public int execute() {
return execute(null);
}
- public int execute(XToolkit.XErrorHandler errorHandler) {
+ public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
if (isDisposed()) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Fri May 15 15:40:35 2009 +0400
@@ -149,63 +149,78 @@
setBackingStoreType();
}
m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ;
+
+ noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
+ }
+
+ //---- 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;
+ current_error_handler = handler;
}
- // 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) {
- saved_error = null;
- curErrorHandler = handler;
- XSync();
- saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
+ public static void RESTORE_XERROR_HANDLER() {
+ current_error_handler = null;
}
- static void XERROR_SAVE(XErrorEvent event) {
- saved_error = event;
- }
+
// Should be called under LOCK
- static void RESTORE_XERROR_HANDLER() {
- XSync();
- XlibWrapper.XSetErrorHandler(saved_error_handler);
- curErrorHandler = null;
- }
- // Should be called under LOCK
- static int SAVED_ERROR_HANDLER(long display, XErrorEvent error) {
- return XlibWrapper.CallErrorHandler(saved_error_handler, display, error.pData);
+ 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;
}
- interface XErrorHandler {
- int handleError(long display, XErrorEvent err);
- }
- 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 @@
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 @@
return new XDesktopPeer();
}
- public static native void setNoisyXErrorHandler();
-
public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
return areExtraMouseButtonsEnabled;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XTranslateCoordinates.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTranslateCoordinates.java Fri May 15 15:40:35 2009 +0400
@@ -57,7 +57,7 @@
public int execute() {
return execute(null);
}
- public int execute(XToolkit.XErrorHandler errorHandler) {
+ public int execute(XErrorHandler errorHandler) {
XToolkit.awtLock();
try {
if (isDisposed()) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XWM.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWM.java Fri May 15 15:40:35 2009 +0400
@@ -276,7 +276,7 @@
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 @@
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 @@
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) {
@@ -571,21 +571,6 @@
}
/*
- * 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.
*
* The only way to detect IceWM, seems to be by setting
@@ -617,7 +602,7 @@
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 @@
* 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.
--- a/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XlibUtil.java Fri May 15 15:40:35 2009 +0400
@@ -149,7 +149,7 @@
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 @@
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 @@
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();
--- a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java Fri May 15 15:40:35 2009 +0400
@@ -646,4 +646,6 @@
String javaVersion = XToolkit.getSystemProperty("java.version");
return javaVersion != null && javaVersion.contains("internal");
}
+
+ static native void PrintXErrorEvent(long display, long event_ptr);
}
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Fri May 15 15:40:35 2009 +0400
@@ -175,42 +175,11 @@
}
#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 @@
return NULL;
}
- XSetErrorHandler(xerror_handler);
XSetIOErrorHandler(xioerror_handler);
/* set awt_numScreens, and whether or not we're using Xinerama */
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Fri May 15 15:40:35 2009 +0400
@@ -1458,7 +1458,6 @@
}
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 @@
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) {
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.c Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_MToolkit.c Fri May 15 15:40:35 2009 +0400
@@ -1926,26 +1926,6 @@
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() */
/*
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c Fri May 15 15:40:35 2009 +0400
@@ -575,7 +575,6 @@
pollFds[1].revents = 0;
}
-
AWT_NOFLUSH_UNLOCK();
/* ACTUALLY DO THE POLL() */
@@ -684,8 +683,6 @@
return ret;
}
-static XErrorHandler saved_error_handler = NULL;
-
#ifdef __linux__
void print_stack(void)
{
@@ -706,38 +703,6 @@
}
#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;
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Wed May 06 20:06:23 2009 +0400
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c Fri May 15 15:40:35 2009 +0400
@@ -1186,7 +1186,7 @@
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 @@
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);
+ }
+}
/*