8030708: warnings from b119 for jdk/src/share/back: JNI exception pending
Summary: Added some more checks for pending exception
Reviewed-by: dholmes, sspitsyn
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/StringReferenceImpl.c Thu Mar 05 09:38:45 2015 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/StringReferenceImpl.c Thu Mar 05 05:06:00 2015 -0800
@@ -46,8 +46,10 @@
char *utf;
utf = (char *)JNI_FUNC_PTR(env,GetStringUTFChars)(env, string, NULL);
- (void)outStream_writeString(out, utf);
- JNI_FUNC_PTR(env,ReleaseStringUTFChars)(env, string, utf);
+ if (!(*env)->ExceptionCheck(env)) {
+ (void)outStream_writeString(out, utf);
+ JNI_FUNC_PTR(env,ReleaseStringUTFChars)(env, string, utf);
+ }
} END_WITH_LOCAL_REFS(env);
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c Thu Mar 05 09:38:45 2015 +0000
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/commonRef.c Thu Mar 05 05:06:00 2015 -0800
@@ -98,7 +98,9 @@
/* Create weak reference to make sure we have a reference */
weakRef = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, ref);
- if (weakRef == NULL) {
+ // NewWeakGlobalRef can throw OOM, clear exception here.
+ if ((*env)->ExceptionCheck(env)) {
+ (*env)->ExceptionClear(env);
jvmtiDeallocate(node);
return NULL;
}
@@ -154,6 +156,7 @@
/*
* NewGlobalRef on a weak ref will return NULL if the weak
* reference has been collected or if out of memory.
+ * It never throws OOM.
* We need to distinguish those two occurrences.
*/
if ((strongRef == NULL) && !isSameObject(env, node->ref, NULL)) {
@@ -178,6 +181,11 @@
jweak weakRef;
weakRef = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, node->ref);
+ // NewWeakGlobalRef can throw OOM, clear exception here.
+ if ((*env)->ExceptionCheck(env)) {
+ (*env)->ExceptionClear(env);
+ }
+
if (weakRef != NULL) {
JNI_FUNC_PTR(env,DeleteGlobalRef)(env, node->ref);
node->ref = weakRef;
@@ -452,6 +460,7 @@
jobject lref;
lref = JNI_FUNC_PTR(env,NewLocalRef)(env, node->ref);
+ // NewLocalRef never throws OOM.
if ( lref == NULL ) {
/* Object was GC'd shortly after we found the node */
deleteNodeByID(env, node->seqNum, ALL_REFS);