Hi list,

I wanna start a new trend on this mailing list now. I wanna ask for approving 
the attached patch. This patch fixes two bugs with files.

1) java.io.File.list() uses an internal method called listInternal(). This 
methods returns null in the error case. list() now converts this to a 
String[0] array which is similar to an empty directory. This behaviour is 
incorrect. We should return the null in the error case.

2) Java_java_io_File_listInternal doest release local references to a newly 
created string. This patch fixes this.

Please review and comment.

mjw: Okay to commit ?


Michael


2004-01-10  Michael Koch  <[EMAIL PROTECTED]>

        * java/io/File.java
        (list): Return null in error case.
        * native/jni/java-io/java_io_File.c
        (Java_java_io_File_listInternal): release local reference.

Index: java/io/File.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.37
diff -u -b -B -r1.37 File.java
--- java/io/File.java	21 Oct 2003 14:53:54 -0000	1.37
+++ java/io/File.java	10 Jan 2004 22:39:01 -0000
@@ -670,8 +670,10 @@
     
     String files[] = listInternal(list_path);
     
+    // Check if an error occured in listInternal().
     if (files == null)
-      return new String[0];
+      return null;
+
     if (filter == null)
       return files;
     
Index: native/jni/java-io/java_io_File.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/java_io_File.c,v
retrieving revision 1.9
diff -u -b -B -r1.9 java_io_File.c
--- native/jni/java-io/java_io_File.c	19 Aug 2003 08:59:56 -0000	1.9
+++ native/jni/java-io/java_io_File.c	10 Jan 2004 22:39:01 -0000
@@ -682,6 +682,9 @@
 
       /* save into array */
       (*env)->SetObjectArrayElement(env, filearray, i, str);
+
+      /* delete local reference */
+      (*env)->DeleteLocalRef(env, str);
     }
 
   /* free resources */
_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to