8025309: [parfait] JNI-related warnings from b107 for jdk.src.share.native.sun.java2d.pipe
authorjchen
Thu, 03 Oct 2013 13:35:26 -0700
changeset 20423 23b2db6ffff4
parent 20422 1a47790e7d9b
child 20424 eace1945b974
8025309: [parfait] JNI-related warnings from b107 for jdk.src.share.native.sun.java2d.pipe Reviewed-by: prr, jgodinez
jdk/src/share/native/sun/java2d/pipe/BufferedRenderPipe.c
jdk/src/share/native/sun/java2d/pipe/Region.c
jdk/src/share/native/sun/java2d/pipe/ShapeSpanIterator.c
jdk/src/share/native/sun/java2d/pipe/SpanClipRenderer.c
--- a/jdk/src/share/native/sun/java2d/pipe/BufferedRenderPipe.c	Thu Oct 03 13:26:45 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/pipe/BufferedRenderPipe.c	Thu Oct 03 13:35:26 2013 -0700
@@ -53,6 +53,7 @@
     unsigned char *bbuf;
     jint *ibuf;
     jint ipos;
+    jboolean hasException;
 
     J2dTraceLn2(J2D_TRACE_INFO,
                 "BufferedRenderPipe_fillSpans: bpos=%d limit=%d",
@@ -104,7 +105,10 @@
             ibuf[1] = spanCount;
 
             // flush the queue
-            JNU_CallMethodByName(env, NULL, rq, "flushNow", "(I)V", bpos);
+            JNU_CallMethodByName(env, &hasException, rq, "flushNow", "(I)V", bpos);
+            if (hasException) {
+                break;
+            }
 
             // now start a new operation
             ibuf = (jint *)bbuf;
--- a/jdk/src/share/native/sun/java2d/pipe/Region.c	Thu Oct 03 13:26:45 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/pipe/Region.c	Thu Oct 03 13:35:26 2013 -0700
@@ -260,6 +260,10 @@
             /* return; REMIND: What to do here? */
         }
         Region_StartIteration(env, &clipInfo);
+        if ((*env)->ExceptionCheck(env)) {
+            return 0;
+        }
+
         numrects = Region_CountIterationRects(&clipInfo);
         if ((unsigned long)numrects > initialBufferSize) {
             *pRect = (RECT_T *) SAFE_SIZE_ARRAY_ALLOC(malloc, numrects, sizeof(RECT_T));
--- a/jdk/src/share/native/sun/java2d/pipe/ShapeSpanIterator.c	Thu Oct 03 13:26:45 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/pipe/ShapeSpanIterator.c	Thu Oct 03 13:35:26 2013 -0700
@@ -653,12 +653,15 @@
                     pd->curx = x;
                     pd->cury = y;
                 }
+                (*env)->ReleasePrimitiveArrayCritical(env, yArray,
+                                                      yPoints, JNI_ABORT);
             }
-            (*env)->ReleasePrimitiveArrayCritical(env, yArray,
-                                                  yPoints, JNI_ABORT);
+            (*env)->ReleasePrimitiveArrayCritical(env, xArray,
+                                                  xPoints, JNI_ABORT);
         }
-        (*env)->ReleasePrimitiveArrayCritical(env, xArray,
-                                              xPoints, JNI_ABORT);
+        if (xPoints == NULL || yPoints == NULL) {
+            return;
+        }
     }
     if (!oom) {
         HANDLEENDPATH(pd, {oom = JNI_TRUE;});
--- a/jdk/src/share/native/sun/java2d/pipe/SpanClipRenderer.c	Thu Oct 03 13:26:45 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/pipe/SpanClipRenderer.c	Thu Oct 03 13:35:26 2013 -0700
@@ -44,21 +44,27 @@
 {
     /* Region fields */
     pBandsArrayID = (*env)->GetFieldID(env, rc, "bands", "[I");
+    if (pBandsArrayID == NULL) {
+        return;
+    }
     pEndIndexID = (*env)->GetFieldID(env, rc, "endIndex", "I");
+    if (pEndIndexID == NULL) {
+        return;
+    }
 
     /* RegionIterator fields */
     pRegionID = (*env)->GetFieldID(env, ric, "region",
                                    "Lsun/java2d/pipe/Region;");
+    if (pRegionID == NULL) {
+        return;
+    }
     pCurIndexID = (*env)->GetFieldID(env, ric, "curIndex", "I");
+    if (pCurIndexID == NULL) {
+        return;
+    }
     pNumXbandsID = (*env)->GetFieldID(env, ric, "numXbands", "I");
-
-    if((pBandsArrayID == NULL)
-       || (pEndIndexID == NULL)
-       || (pRegionID == NULL)
-       || (pCurIndexID == NULL)
-       || (pNumXbandsID == NULL))
-    {
-        JNU_ThrowInternalError(env, "NULL field ID");
+    if (pNumXbandsID == NULL) {
+        return;
     }
 }
 
@@ -129,10 +135,14 @@
 
     if ((*env)->GetArrayLength(env, boxArray) < 4) {
         JNU_ThrowArrayIndexOutOfBoundsException(env, "band array");
+        return;
     }
     alphalen = (*env)->GetArrayLength(env, alphaTile);
 
     box = (*env)->GetPrimitiveArrayCritical(env, boxArray, 0);
+    if (box == NULL) {
+        return;
+    }
 
     w = box[2] - box[0];
     h = box[3] - box[1];
@@ -140,9 +150,14 @@
     if (alphalen < offset || (alphalen - offset) / tsize < h) {
         (*env)->ReleasePrimitiveArrayCritical(env, boxArray, box, 0);
         JNU_ThrowArrayIndexOutOfBoundsException(env, "alpha tile array");
+        return;
     }
 
     alpha = (*env)->GetPrimitiveArrayCritical(env, alphaTile, 0);
+    if (alpha == NULL) {
+        (*env)->ReleasePrimitiveArrayCritical(env, boxArray, box, 0);
+        return;
+    }
 
     fill(alpha, offset, tsize, 0, 0, w, h, (jbyte) 0xff);
 
@@ -182,6 +197,7 @@
 
     if ((*env)->GetArrayLength(env, boxArray) < 4) {
         JNU_ThrowArrayIndexOutOfBoundsException(env, "band array");
+        return;
     }
     alphalen = (*env)->GetArrayLength(env, alphaTile);
 
@@ -196,6 +212,9 @@
     }
 
     box = (*env)->GetPrimitiveArrayCritical(env, boxArray, 0);
+    if (box == NULL) {
+        return;
+    }
 
     lox = box[0];
     loy = box[1];
@@ -207,10 +226,20 @@
         (alphalen - offset - (hix-lox)) / tsize < (hiy - loy - 1)) {
         (*env)->ReleasePrimitiveArrayCritical(env, boxArray, box, 0);
         JNU_ThrowArrayIndexOutOfBoundsException(env, "alpha tile array");
+        return;
     }
 
     bands = (*env)->GetPrimitiveArrayCritical(env, bandsArray, 0);
+    if (bands == NULL) {
+        (*env)->ReleasePrimitiveArrayCritical(env, boxArray, box, 0);
+        return;
+    }
     alpha = (*env)->GetPrimitiveArrayCritical(env, alphaTile, 0);
+    if (alpha == NULL) {
+        (*env)->ReleasePrimitiveArrayCritical(env, bandsArray, bands, 0);
+        (*env)->ReleasePrimitiveArrayCritical(env, boxArray, box, 0);
+        return;
+    }
 
     curIndex = saveCurIndex;
     numXbands = saveNumXbands;