8030788: [Parfait] warnings from b119 for jdk/src/share/native/sun/awt/medialib: JNI exception pending
authorpchelko
Mon, 24 Feb 2014 12:51:58 +0400
changeset 23314 8e5e3abbbd12
parent 23313 f100f0d49e0b
child 23315 02c932be7d63
8030788: [Parfait] warnings from b119 for jdk/src/share/native/sun/awt/medialib: JNI exception pending Reviewed-by: serb, prr
jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
--- a/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Fri Feb 21 15:28:39 2014 -0800
+++ b/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Mon Feb 24 12:51:58 2014 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1106,6 +1106,7 @@
     if (ddata == NULL) {
         /* Need to store it back into the array */
         if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
+            (*env)->ExceptionClear(env); // Could not store the array, try another way
             retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
         }
     }
@@ -2014,6 +2015,7 @@
 
     jpixels = (*env)->NewIntArray(env, nbytes);
     if (JNU_IsNull(env, jpixels)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -2079,6 +2081,7 @@
 
     jpixels = (*env)->NewIntArray(env, nbytes);
     if (JNU_IsNull(env, jpixels)) {
+        (*env)->ExceptionClear(env);
         JNU_ThrowOutOfMemoryError(env, "Out of Memory");
         return -1;
     }
@@ -2775,21 +2778,14 @@
 
     /* Need to grab the lookup tables.  Right now only bytes */
     rgb = (int *) (*env)->GetPrimitiveArrayCritical(env, cmP->jrgb, NULL);
+    CHECK_NULL_RETURN(rgb, -1);
 
     /* Interleaved with shared data */
     dataP = (void *) (*env)->GetPrimitiveArrayCritical(env,
                                                        rasterP->jdata, NULL);
-    if (rgb == NULL || dataP == NULL) {
+    if (dataP == NULL) {
         /* Release the lookup tables */
-        if (rgb) {
-            (*env)->ReleasePrimitiveArrayCritical(env, cmP->jrgb, rgb,
-                                                  JNI_ABORT);
-        }
-        if (dataP) {
-            (*env)->ReleasePrimitiveArrayCritical(env,
-                                                  rasterP->jdata, dataP,
-                                                  JNI_ABORT);
-        }
+        (*env)->ReleasePrimitiveArrayCritical(env, cmP->jrgb, rgb, JNI_ABORT);
         return -1;
     }