--- a/jdk/src/solaris/native/sun/awt/awt_util.h Tue May 21 03:20:27 2013 +0400
+++ b/jdk/src/solaris/native/sun/awt/awt_util.h Tue May 21 05:02:21 2013 +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
@@ -29,42 +29,47 @@
#ifndef HEADLESS
#include "gdefs.h"
-#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; \
-} while (0)
-
-#define RESTORE_XERROR_HANDLER do { \
- XSync(awt_display, False); \
- XSetErrorHandler(xerror_saved_handler); \
-} 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)
+ */
+#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)
/*
- * 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.
+ * (JNIEnv*)
*/
-extern XErrorHandler xerror_saved_handler;
+#define RESTORE_XERROR_HANDLER(env) do { \
+ JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \
+ "RESTORE_XERROR_HANDLER", "()V"); \
+} while (0)
/*
- * A place for error handler to report the error code.
+ * Expected types of arguments of the macro.
+ * (JNIEnv*, const char*, const char*, jboolean, jobject, jboolean, No type - C expression)
*/
-extern unsigned char xerror_code;
-
+#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); \
+ if (handlerHasFlag == JNI_TRUE) { \
+ errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", \
+ "()Z").z; \
+ } \
+} while (0)
#endif /* !HEADLESS */
#ifndef INTERSECTS