Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 6455 invoked from network); 7 Feb 2006 12:57:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Feb 2006 12:57:28 -0000 Received: (qmail 6479 invoked by uid 500); 7 Feb 2006 12:57:18 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 6406 invoked by uid 500); 7 Feb 2006 12:57:17 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 6395 invoked by uid 99); 7 Feb 2006 12:57:17 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2006 04:57:17 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 07 Feb 2006 04:57:16 -0800 Received: (qmail 6032 invoked by uid 65534); 7 Feb 2006 12:56:28 -0000 Message-ID: <20060207125626.5955.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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()); } }