8030875: Macros for checking and returning on exceptions
authorrriggs
Fri, 10 Jan 2014 10:45:56 -0500
changeset 22258 db80f864ed8f
parent 22257 0266d88a6ec6
child 22259 8e5afc67dca8
8030875: Macros for checking and returning on exceptions Summary: Move exception checking macros to common jni_util.h Reviewed-by: chegar
jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp
jdk/src/share/native/com/sun/java/util/jar/pack/defines.h
jdk/src/share/native/common/jni_util.h
jdk/src/share/native/java/net/net_util.h
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp	Fri Jan 10 16:17:34 2014 +0100
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/coding.cpp	Fri Jan 10 10:45:56 2014 -0500
@@ -32,6 +32,8 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
+#include "jni_util.h"
+
 #include "defines.h"
 #include "bytes.h"
 #include "utils.h"
@@ -147,7 +149,7 @@
       break;
   }
   coding* ptr = NEW(coding, 1);
-  CHECK_NULL_0(ptr);
+  CHECK_NULL_RETURN(ptr, 0);
   coding* c = ptr->initFrom(spec);
   if (c == null) {
     mtrace('f', ptr, 0);
--- a/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/jdk/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Jan 10 10:45:56 2014 -0500
@@ -158,10 +158,6 @@
 #define CHECK_(y)               _CHECK_DO(aborting(), return y)
 #define CHECK_0                 _CHECK_DO(aborting(), return 0)
 
-#define CHECK_NULL(p)           _CHECK_DO((p)==null, return)
-#define CHECK_NULL_(y,p)        _CHECK_DO((p)==null, return y)
-#define CHECK_NULL_0(p)         _CHECK_DO((p)==null, return 0)
-
 #define CHECK_COUNT(t)          if (t < 0){abort("bad value count");} CHECK
 
 #define STR_TRUE   "true"
--- a/jdk/src/share/native/common/jni_util.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/jdk/src/share/native/common/jni_util.h	Fri Jan 10 10:45:56 2014 -0500
@@ -278,6 +278,15 @@
 #define IS_NULL(obj) ((obj) == NULL)
 #define JNU_IsNull(env,obj) ((obj) == NULL)
 
+/************************************************************************
+ * Miscellaneous utilities used by the class libraries to check for exceptions
+ */
+
+#define CHECK_NULL(x) if ((x) == NULL) return;
+#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return (y);
+
+#define CHECK_EXCEPTION(env) if ((*env)->ExceptionCheck(env)) return;
+#define CHECK_EXCEPTION_RETURN(env, y) if ((*env)->ExceptionCheck(env)) return (y);
 
 /************************************************************************
  * Debugging utilities
--- a/jdk/src/share/native/java/net/net_util.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/jdk/src/share/native/java/net/net_util.h	Fri Jan 10 10:45:56 2014 -0500
@@ -42,9 +42,6 @@
 #define NET_ERROR(env, ex, msg) \
 { if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg) }
 
-#define CHECK_NULL(x) if ((x) == NULL) return;
-#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return y;
-
 /************************************************************************
  * Cached field IDs
  *