harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r375590 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/File.java test/java/org/apache/harmony/tests/java/io/FileTest.java
Date Tue, 07 Feb 2006 12:55:19 GMT
Author: tellison
Date: Tue Feb  7 04:54:25 2006
New Revision: 375590

URL: http://svn.apache.org/viewcvs?rev=375590&view=rev
Log:
Fix for HARMONY-46 (Constructor java.io.File(String) creates object with incorrect name if
one-letter name is followed by file separator char)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java?rev=375590&r1=375589&r2=375590&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/File.java
Tue Feb  7 04:54:25 2006
@@ -263,14 +263,18 @@
 						&& newPath[0] == separatorChar) {
 					newPath[0] = newPath[newLength - 1];
 					newLength = 1;
+					// allow trailing slash after drive letter
+					uncIndex = 2;
 				}
 				newPath[newLength++] = pathChar;
 				foundSlash = false;
 			}
 		}
 		// remove trailing slash
-		if (foundSlash && newLength > (uncIndex + 1))
+		if (foundSlash
+				&& (newLength > (uncIndex + 1) || (newLength == 2 && newPath[0] !=
separatorChar))) {
 			newLength--;
+		}
 		String tempPath = new String(newPath, 0, newLength);
 		// If it's the same keep it identical for SecurityManager purposes
 		if (!tempPath.equals(origPath)) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileTest.java?rev=375590&r1=375589&r2=375590&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/FileTest.java
Tue Feb  7 04:54:25 2006
@@ -59,6 +59,11 @@
 		f = new File((File) null, fileName);
 		assertTrue("Assert 4: Created incorrect file " + f.getPath(), f
 				.getAbsolutePath().equals(dirName));
+		
+		// Regression for HARMONY-46
+		File f1 = new File("a");
+		File f2 = new File("a/");
+		assertEquals("Assert 5: Trailing slash file name is incorrect", f1, f2);
 	}
 	
 	/**
@@ -70,12 +75,10 @@
 		File mfile = new File(mixedFname);
 		File lfile = new File(mixedFname.toLowerCase());
 
-		int hash = 0;
 		if (mfile.equals(lfile)) {
-			hash = mixedFname.toLowerCase().hashCode() ^ 1234321;
+			assertTrue("Assert 0: wrong hashcode", mfile.hashCode() == lfile.hashCode());
 		} else {
-			hash = mixedFname.hashCode() ^ 1234321;
+			assertFalse("Assert 1: wrong hashcode", mfile.hashCode() == lfile.hashCode());
 		}
-		assertEquals("Assert 0: wrong hashcode", hash, mfile.hashCode());
 	}
 }



Mime
View raw message