--- old/src/solaris/native/sun/awt/awt_util.h 2013-07-12 15:40:21.000000000 +0400 +++ new/src/solaris/native/sun/awt/awt_util.h 2013-07-12 15:40:21.000000000 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2013, 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 @@ -79,44 +79,62 @@ void awt_util_delEmbeddedFrame(Widget embeddedFrame); Boolean awt_util_processEventForEmbeddedFrame(XEvent *ev); -#define WITH_XERROR_HANDLER(f) do { \ - XSync(awt_display, False); \ - xerror_code = Success; \ - xerror_saved_handler = XSetErrorHandler(f); \ -} while (0) - -/* Convenience macro for handlers to use */ -#define XERROR_SAVE(err) do { \ - xerror_code = (err)->error_code; \ +/* + * Expected types of arguments of the macro. + * (JNIEnv*, const char*, const char*, jboolean, jobject) + */ +#define WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, \ + handlerHasFlag, handlerRef) do { \ + handlerRef = JNU_CallStaticMethodByName(env, NULL, handlerClassName, "getInstance", \ + getInstanceSignature).l; \ + if (handlerHasFlag == JNI_TRUE) { \ + JNU_CallMethodByName(env, NULL, handlerRef, "setErrorOccurredFlag", "(Z)V", JNI_FALSE); \ + } \ + JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "WITH_XERROR_HANDLER", \ + "(Lsun/awt/X11/XErrorHandler;)V", handlerRef); \ } while (0) -#define RESTORE_XERROR_HANDLER do { \ - XSync(awt_display, False); \ - XSetErrorHandler(xerror_saved_handler); \ +/* + * Expected types of arguments of the macro. + * (JNIEnv*, jboolean) + */ +#define RESTORE_XERROR_HANDLER(env, doXSync) do { \ + JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \ + "RESTORE_XERROR_HANDLER", "(Z)V", doXSync); \ } while (0) -#define EXEC_WITH_XERROR_HANDLER(f, code) do { \ - WITH_XERROR_HANDLER(f); \ - do { \ - code; \ - } while (0); \ - RESTORE_XERROR_HANDLER; \ +/* + * Expected types of arguments of the macro. + * (JNIEnv*, const char*, const char*, jboolean, jobject, jboolean, No type - C expression) + */ +#define EXEC_WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, \ + handlerRef, errorOccurredFlag, code) do { \ + handlerRef = NULL; \ + WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, handlerRef); \ + do { \ + code; \ + } while (0); \ + RESTORE_XERROR_HANDLER(env, JNI_TRUE); \ + if (handlerHasFlag == JNI_TRUE) { \ + errorOccurredFlag = GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef); \ + } \ } while (0) /* - * Since X reports protocol errors asynchronously, we often need to - * install an error handler that acts like a callback. While that - * specialized handler is installed we save original handler here. + * Expected types of arguments of the macro for jboolean expression. + * (JNIEnv*, jobject) */ -extern XErrorHandler xerror_saved_handler; +#define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef) (handlerRef != NULL ? \ + JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", "()Z").z : JNI_FALSE) /* - * A place for error handler to report the error code. + * Expected types of arguments of the macro for jbyte expression. + * (JNIEnv*, jobject) */ -extern unsigned char xerror_code; - -extern int xerror_ignore_bad_window(Display *dpy, XErrorEvent *err); - +#define GET_XERROR_CODE(env, savedError) \ + ((savedError = JNU_GetStaticFieldByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \ + "saved_error", "Lsun/awt/X11/XErrorEvent;").l) != NULL ? \ + JNU_CallMethodByName(env, NULL, savedError, "get_error_code", "()B").b : Success) #endif /* !HEADLESS */ #ifndef INTERSECTS