harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r452026 - in /incubator/harmony/enhanced/classlib/trunk/modules: archive/src/main/native/archive/shared/jarfile.c archive/src/main/native/archive/shared/zip.c luni/src/main/native/luni/shared/file.c
Date Mon, 02 Oct 2006 13:18:17 GMT
Author: tellison
Date: Mon Oct  2 06:18:16 2006
New Revision: 452026

URL: http://svn.apache.org/viewvc?view=rev&rev=452026
Log:
Fix JNI warnings, dangerous use of weak reference.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/jarfile.c
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/jarfile.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/jarfile.c?view=diff&rev=452026&r1=452025&r2=452026
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/jarfile.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/jarfile.c
Mon Oct  2 06:18:16 2006
@@ -55,6 +55,11 @@
     }
 
   javaClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+  javaClass = (*env)->NewLocalRef(env, javaClass);
+  if (javaClass == NULL) {
+      return NULL;
+  }
+
   mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
   java_ZipEntry = ((*env)->NewObject (env, javaClass, mid, entryName, NULL,
 				      extra,
@@ -152,6 +157,11 @@
 	    goto cleanup;
 	}
       javaClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+	  javaClass = (*env)->NewLocalRef(env, javaClass);
+      if (javaClass == NULL) {
+          result = NULL;
+          goto cleanup;
+      }
       result = ((*env)->NewObjectArray (env, resultCount, javaClass, NULL));
       if (((*env)->ExceptionCheck (env)))
 	{

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c?view=diff&rev=452026&r1=452025&r2=452026
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
Mon Oct  2 06:18:16 2006
@@ -155,6 +155,11 @@
     }
 
   entryClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+  entryClass = (*env)->NewLocalRef(env, entryClass);
+  if (entryClass == NULL) {
+    zip_freeZipEntry (PORTLIB, &zipEntry);
+    return (jobject) NULL;
+  }
   mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
   /* Build a new ZipEntry from the C struct */
   java_ZipEntry = ((*env)->NewObject (env, entryClass, mid, entryName, NULL,
@@ -227,11 +232,12 @@
   jmethodID mid;
   jfieldID descriptorFID;
   jclass javaClass;
+  jclass weakJavaClass;
   JCLZipFileLink *zipfileHandles;
 
   javaClass = (*env)->FindClass (env, "java/util/zip/ZipEntry");
-  javaClass = (*env)->NewWeakGlobalRef (env, javaClass);
-  if (!javaClass)
+  weakJavaClass = (*env)->NewWeakGlobalRef (env, javaClass);
+  if (!weakJavaClass)
     return;
   mid =
     ((*env)->
@@ -239,7 +245,7 @@
                   "(Ljava/lang/String;Ljava/lang/String;[BJJJJIJJ)V"));
   if (!mid)
     return;
-  JCL_CACHE_SET (env, CLS_java_util_zip_ZipEntry, javaClass);
+  JCL_CACHE_SET (env, CLS_java_util_zip_ZipEntry, weakJavaClass);
   JCL_CACHE_SET (env, MID_java_util_zip_ZipEntry_init, mid);
 
   descriptorFID = (*env)->GetFieldID (env, cls, "descriptor", "J");
@@ -351,6 +357,10 @@
     }
 
   javaClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
+  javaClass = (*env)->NewLocalRef(env, javaClass);
+  if (javaClass == NULL) {
+      return NULL;
+  }
   mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
   java_ZipEntry = ((*env)->NewObject (env, javaClass, mid, entryName, NULL,     /* comment
*/
                                       extra,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c?view=diff&rev=452026&r1=452025&r2=452026
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/file.c
Mon Oct  2 06:18:16 2006
@@ -70,6 +70,8 @@
   I_32 numEntries = 0;
   UDATA findhandle;
   jarray answer = NULL;
+  jclass javaClass = NULL;
+
   dirList = NULL;
   currentEntry = NULL;
 
@@ -123,9 +125,13 @@
   if (numEntries == 0)
     return NULL;
 
+  javaClass = JCL_CACHE_GET (env, CLS_array_of_byte);
+  javaClass = (*env)->NewLocalRef(env, javaClass);
+  if (javaClass == NULL) {
+      return NULL;
+  }
   answer =
-    (*env)->NewObjectArray (env, numEntries,
-                            JCL_CACHE_GET (env, CLS_array_of_byte), NULL);
+    (*env)->NewObjectArray (env, numEntries, javaClass, NULL);
 cleanup:
   for (index = 0; index < numEntries; index++)
     {



Mime
View raw message