8024697: Fix for 8020983 causes Xcheck:jni warnings
authorbae
Fri, 13 Sep 2013 20:28:17 +0400
changeset 19788 2899c95495a9
parent 19787 3e181c0c042b
child 19789 130346400f59
8024697: Fix for 8020983 causes Xcheck:jni warnings Reviewed-by: prr, jchen
jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
jdk/test/javax/imageio/plugins/jpeg/JpegWriterLeakTest.java
--- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Tue Sep 10 21:54:14 2013 +0400
+++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Fri Sep 13 20:28:17 2013 +0400
@@ -930,9 +930,10 @@
      * Now fill a complete buffer, or as much of one as the stream
      * will give us if we are near the end.
      */
+    RELEASE_ARRAYS(env, data, src->next_input_byte);
+
     GET_IO_REF(input);
 
-    RELEASE_ARRAYS(env, data, src->next_input_byte);
     ret = (*env)->CallIntMethod(env,
                                 input,
                                 JPEGImageReader_readInputDataID,
@@ -1017,9 +1018,11 @@
         memcpy(sb->buf, src->next_input_byte, offset);
     }
 
-    GET_IO_REF(input);
 
     RELEASE_ARRAYS(env, data, src->next_input_byte);
+
+    GET_IO_REF(input);
+
     buflen = sb->bufferLength - offset;
     if (buflen <= 0) {
         if (!GET_ARRAYS(env, data, &(src->next_input_byte))) {
@@ -1121,9 +1124,10 @@
         return;
     }
 
+    RELEASE_ARRAYS(env, data, src->next_input_byte);
+
     GET_IO_REF(input);
 
-    RELEASE_ARRAYS(env, data, src->next_input_byte);
     ret = (*env)->CallLongMethod(env,
                                  input,
                                  JPEGImageReader_skipInputBytesID,
@@ -2306,10 +2310,10 @@
     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
     jobject output = NULL;
 
+    RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
+
     GET_IO_REF(output);
 
-    RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
-
     (*env)->CallVoidMethod(env,
                            output,
                            JPEGImageWriter_writeOutputDataID,
@@ -2348,10 +2352,10 @@
     if (datacount != 0) {
         jobject output = NULL;
 
+        RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
+
         GET_IO_REF(output);
 
-        RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte));
-
         (*env)->CallVoidMethod(env,
                                output,
                                JPEGImageWriter_writeOutputDataID,
--- a/jdk/test/javax/imageio/plugins/jpeg/JpegWriterLeakTest.java	Tue Sep 10 21:54:14 2013 +0400
+++ b/jdk/test/javax/imageio/plugins/jpeg/JpegWriterLeakTest.java	Fri Sep 13 20:28:17 2013 +0400
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug     8020983
+ * @bug     8020983 8024697
  * @summary Test verifies that jpeg writer instances are collected
  *          even if destroy() or reset() methods is not invoked.
  *