changeset 9701:8c97df2d2e7c

8029018: (bf) Check src/share/native/java/nio/Bits.c for JNI pending exceptions Reviewed-by: chegar
author alanb
date Fri, 03 Jan 2014 15:42:05 +0000
parents 0d2ec8760dbc
children feba444e5167
files src/share/native/java/nio/Bits.c
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/native/java/nio/Bits.c	Thu Jan 31 05:57:31 2019 +0000
+++ b/src/share/native/java/nio/Bits.c	Fri Jan 03 15:42:05 2014 +0000
@@ -51,10 +51,13 @@
 
 #define MBYTE 1048576
 
-#define GETCRITICAL(bytes, env, obj) { \
+#define GETCRITICAL_OR_RETURN(bytes, env, obj) { \
     bytes = (*env)->GetPrimitiveArrayCritical(env, obj, NULL); \
-    if (bytes == NULL) \
-        JNU_ThrowInternalError(env, "Unable to get array"); \
+    if (bytes == NULL)  { \
+        if ((*env)->ExceptionOccurred(env) == NULL) \
+            JNU_ThrowInternalError(env, "Unable to get array"); \
+        return; \
+    } \
 }
 
 #define RELEASECRITICAL(bytes, env, obj, mode) { \
@@ -85,7 +88,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, src);
+        GETCRITICAL_OR_RETURN(bytes, env, src);
 
         srcShort = (jshort *)(bytes + srcPos);
         endShort = srcShort + (size / sizeof(jshort));
@@ -120,7 +123,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, dst);
+        GETCRITICAL_OR_RETURN(bytes, env, dst);
 
         dstShort = (jshort *)(bytes + dstPos);
         endShort = srcShort + (size / sizeof(jshort));
@@ -155,7 +158,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, src);
+        GETCRITICAL_OR_RETURN(bytes, env, src);
 
         srcInt = (jint *)(bytes + srcPos);
         endInt = srcInt + (size / sizeof(jint));
@@ -190,7 +193,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, dst);
+        GETCRITICAL_OR_RETURN(bytes, env, dst);
 
         dstInt = (jint *)(bytes + dstPos);
         endInt = srcInt + (size / sizeof(jint));
@@ -225,7 +228,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, src);
+        GETCRITICAL_OR_RETURN(bytes, env, src);
 
         srcLong = (jlong *)(bytes + srcPos);
         endLong = srcLong + (size / sizeof(jlong));
@@ -260,7 +263,7 @@
         else
             size = (size_t)length;
 
-        GETCRITICAL(bytes, env, dst);
+        GETCRITICAL_OR_RETURN(bytes, env, dst);
 
         dstLong = (jlong *)(bytes + dstPos);
         endLong = srcLong + (size / sizeof(jlong));