8025480: [parfait] "JNI exception pending" warnings from b107 for jdk.src.share.native.sun.java2d
authorjchen
Thu, 03 Oct 2013 13:26:45 -0700
changeset 20422 1a47790e7d9b
parent 20421 8fab9959a1bc
child 20423 23b2db6ffff4
8025480: [parfait] "JNI exception pending" warnings from b107 for jdk.src.share.native.sun.java2d Reviewed-by: prr, jgodinez
jdk/src/share/native/sun/java2d/Disposer.c
jdk/src/share/native/sun/java2d/SurfaceData.c
--- a/jdk/src/share/native/sun/java2d/Disposer.c	Thu Oct 03 13:16:31 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/Disposer.c	Thu Oct 03 13:26:45 2013 -0700
@@ -38,10 +38,9 @@
 {
     addRecordMID = (*env)->GetStaticMethodID(env, disposerClass, "addRecord",
                                              "(Ljava/lang/Object;JJ)V");
-    if (addRecordMID == 0) {
-        JNU_ThrowNoSuchMethodError(env, "Disposer.addRecord");
+    if (addRecordMID != 0) {
+        dispClass = (*env)->NewGlobalRef(env, disposerClass);
     }
-    dispClass = (*env)->NewGlobalRef(env, disposerClass);
 }
 
 JNIEXPORT void JNICALL
@@ -50,6 +49,10 @@
     if (dispClass == NULL) {
         /* Needed to initialize the Disposer class as it may be not yet referenced */
         jclass clazz = (*env)->FindClass(env, "sun/java2d/Disposer");
+        if ((*env)->ExceptionCheck(env)) {
+            // If there's exception pending, we'll just return.
+            return;
+        }
     }
 
     (*env)->CallStaticVoidMethod(env, dispClass, addRecordMID,
--- a/jdk/src/share/native/sun/java2d/SurfaceData.c	Thu Oct 03 13:16:31 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/SurfaceData.c	Thu Oct 03 13:26:45 2013 -0700
@@ -237,7 +237,9 @@
     SurfaceData_SetOps(env, sData, ops);
     if (ops != NULL) {
         memset(ops, 0, opsSize);
-        ops->sdObject = (*env)->NewWeakGlobalRef(env, sData);
+        if (!(*env)->ExceptionCheck(env)) {
+            ops->sdObject = (*env)->NewWeakGlobalRef(env, sData);
+        }
     }
     return ops;
 }