changeset 9051:c58c6b0fbe34

8030875: Macros for checking and returning on exceptions Summary: Move exception checking macros to common jni_util.h Reviewed-by: chegar
author rriggs
date Fri, 10 Jan 2014 10:45:56 -0500
parents 8360aced7bd6
children 5206018a9f3d
files src/share/native/com/sun/java/util/jar/pack/coding.cpp src/share/native/com/sun/java/util/jar/pack/defines.h src/share/native/common/jni_util.h src/share/native/java/net/net_util.h
diffstat 4 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/com/sun/java/util/jar/pack/coding.cpp	Fri Jan 10 16:17:34 2014 +0100
+++ b/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/src/share/native/com/sun/java/util/jar/pack/defines.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/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/src/share/native/common/jni_util.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/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/src/share/native/java/net/net_util.h	Fri Jan 10 16:17:34 2014 +0100
+++ b/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
  *