提交 3356b65e 编写于 作者: A alanb

8029018: (bf) Check src/share/native/java/nio/Bits.c for JNI pending exceptions

Reviewed-by: chegar
上级 7d60d7bc
...@@ -51,10 +51,13 @@ ...@@ -51,10 +51,13 @@
#define MBYTE 1048576 #define MBYTE 1048576
#define GETCRITICAL(bytes, env, obj) { \ #define GETCRITICAL_OR_RETURN(bytes, env, obj) { \
bytes = (*env)->GetPrimitiveArrayCritical(env, obj, NULL); \ bytes = (*env)->GetPrimitiveArrayCritical(env, obj, NULL); \
if (bytes == NULL) \ if (bytes == NULL) { \
JNU_ThrowInternalError(env, "Unable to get array"); \ if ((*env)->ExceptionOccurred(env) == NULL) \
JNU_ThrowInternalError(env, "Unable to get array"); \
return; \
} \
} }
#define RELEASECRITICAL(bytes, env, obj, mode) { \ #define RELEASECRITICAL(bytes, env, obj, mode) { \
...@@ -85,7 +88,7 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src, ...@@ -85,7 +88,7 @@ Java_java_nio_Bits_copyFromShortArray(JNIEnv *env, jobject this, jobject src,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, src); GETCRITICAL_OR_RETURN(bytes, env, src);
srcShort = (jshort *)(bytes + srcPos); srcShort = (jshort *)(bytes + srcPos);
endShort = srcShort + (size / sizeof(jshort)); endShort = srcShort + (size / sizeof(jshort));
...@@ -120,7 +123,7 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr, ...@@ -120,7 +123,7 @@ Java_java_nio_Bits_copyToShortArray(JNIEnv *env, jobject this, jlong srcAddr,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, dst); GETCRITICAL_OR_RETURN(bytes, env, dst);
dstShort = (jshort *)(bytes + dstPos); dstShort = (jshort *)(bytes + dstPos);
endShort = srcShort + (size / sizeof(jshort)); endShort = srcShort + (size / sizeof(jshort));
...@@ -155,7 +158,7 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src, ...@@ -155,7 +158,7 @@ Java_java_nio_Bits_copyFromIntArray(JNIEnv *env, jobject this, jobject src,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, src); GETCRITICAL_OR_RETURN(bytes, env, src);
srcInt = (jint *)(bytes + srcPos); srcInt = (jint *)(bytes + srcPos);
endInt = srcInt + (size / sizeof(jint)); endInt = srcInt + (size / sizeof(jint));
...@@ -190,7 +193,7 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr, ...@@ -190,7 +193,7 @@ Java_java_nio_Bits_copyToIntArray(JNIEnv *env, jobject this, jlong srcAddr,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, dst); GETCRITICAL_OR_RETURN(bytes, env, dst);
dstInt = (jint *)(bytes + dstPos); dstInt = (jint *)(bytes + dstPos);
endInt = srcInt + (size / sizeof(jint)); endInt = srcInt + (size / sizeof(jint));
...@@ -225,7 +228,7 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src, ...@@ -225,7 +228,7 @@ Java_java_nio_Bits_copyFromLongArray(JNIEnv *env, jobject this, jobject src,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, src); GETCRITICAL_OR_RETURN(bytes, env, src);
srcLong = (jlong *)(bytes + srcPos); srcLong = (jlong *)(bytes + srcPos);
endLong = srcLong + (size / sizeof(jlong)); endLong = srcLong + (size / sizeof(jlong));
...@@ -260,7 +263,7 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr, ...@@ -260,7 +263,7 @@ Java_java_nio_Bits_copyToLongArray(JNIEnv *env, jobject this, jlong srcAddr,
else else
size = (size_t)length; size = (size_t)length;
GETCRITICAL(bytes, env, dst); GETCRITICAL_OR_RETURN(bytes, env, dst);
dstLong = (jlong *)(bytes + dstPos); dstLong = (jlong *)(bytes + dstPos);
endLong = srcLong + (size / sizeof(jlong)); endLong = srcLong + (size / sizeof(jlong));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册