harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r373152 - 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 Sat, 28 Jan 2006 14:54:52 GMT
Author: tellison
Date: Sat Jan 28 06:54:44 2006
New Revision: 373152

URL: http://svn.apache.org/viewcvs?rev=373152&view=rev
Log:
Fix for HARMONY-53 (java.io.File.hashCode() returns incorrect value)

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=373152&r1=373151&r2=373152&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
Sat Jan 28 06:54:44 2006
@@ -634,7 +634,10 @@
 	 * @see #equals
 	 */
 	public int hashCode() {
-		return path.hashCode() ^ 1234321;
+		if (caseSensitive)
+			return path.hashCode() ^ 1234321;
+		else
+			return path.toLowerCase().hashCode() ^ 1234321;
 	}
 
 	/**

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=373152&r1=373151&r2=373152&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
Sat Jan 28 06:54:44 2006
@@ -60,4 +60,22 @@
 		assertTrue("Assert 4: Created incorrect file " + f.getPath(), f
 				.getAbsolutePath().equals(dirName));
 	}
+	
+	/**
+	 * @tests java.io.File#hashCode()
+	 */
+	public void test_hashCode() {
+		// Regression for HARMONY-53
+		String mixedFname = "SoMe FiLeNaMe";
+		File mfile = new File(mixedFname);
+		File lfile = new File(mixedFname.toLowerCase());
+
+		int hash = 0;
+		if (mfile.equals(lfile)) {
+			hash = mixedFname.toLowerCase().hashCode() ^ 1234321;
+		} else {
+			hash = mixedFname.hashCode() ^ 1234321;
+		}
+		assertEquals("Assert 0: wrong hashcode", hash, mfile.hashCode());
+	}
 }



Mime
View raw message