harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r542430 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/File.java test/java/org/apache/harmony/luni/tests/java/io/FileTest.java
Date Tue, 29 May 2007 06:51:07 GMT
Author: pyang
Date: Mon May 28 23:51:06 2007
New Revision: 542430

URL: http://svn.apache.org/viewvc?view=rev&rev=542430
Log:
Apply patch for HARMONY-3869([classlib][luni] Compatibility: File(, ) differs on Harmony and
RI)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java?view=diff&rev=542430&r1=542429&r2=542430
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java Mon May 28
23:51:06 2007
@@ -44,6 +44,8 @@
  * @see java.lang.Comparable
  */
 public class File implements Serializable, Comparable<File> {
+    private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
     private static final long serialVersionUID = 301077366599181567L;
 
     private String path;
@@ -165,7 +167,7 @@
 
     private String calculatePath(String dirPath, String name) {
         dirPath = fixSlashes(dirPath);
-        if (!name.equals("")) { //$NON-NLS-1$
+        if (!name.equals(EMPTY_STRING) || dirPath.equals(EMPTY_STRING)) { 
             // Remove all the proceeding separator chars from name
             name = fixSlashes(name);
 
@@ -1288,12 +1290,12 @@
         String name = getAbsoluteName();
         if (!name.startsWith("/")) { //$NON-NLS-1$
             // start with sep.
-            return new URL("file", "", -1, new StringBuilder(name.length() + 1) //$NON-NLS-1$
//$NON-NLS-2$
+            return new URL("file", EMPTY_STRING, -1, new StringBuilder(name.length() + 1)
//$NON-NLS-1$ 
                     .append('/').append(name).toString(), null);
         } else if (name.startsWith("//")) { //$NON-NLS-1$
             return new URL("file:" + name); // UNC path //$NON-NLS-1$
         }
-        return new URL("file", "", -1, name, null); //$NON-NLS-1$ //$NON-NLS-2$
+        return new URL("file", EMPTY_STRING, -1, name, null); //$NON-NLS-1$
     }
 
     private String getAbsoluteName() {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java?view=diff&rev=542430&r1=542429&r2=542430
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/io/FileTest.java
Mon May 28 23:51:06 2007
@@ -120,7 +120,12 @@
 
         assertEquals(parent.getPath(), f3.getPath());
         
+        // Regression for HARMONY-3869
+        File file1 = new File("", "");
+        assertEquals(File.separator, file1.getPath());
         
+        File file2 = new File(new File(""), "");
+        assertEquals(File.separator, file2.getPath());
     }
     
     /**



Mime
View raw message