harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-46) Constructor java.io.File(String) creates object with incorrect name if one-letter name is followed by file separator char
Date Thu, 26 Jan 2006 06:08:10 GMT
Constructor  java.io.File(String) creates object with incorrect name if one-letter name is
followed by file separator char
--------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-46
         URL: http://issues.apache.org/jira/browse/HARMONY-46
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Vladimir Ivanov


Constructor  java.io.File(String) creates object with incorrect name if one-letter name is
followed by file separator char.

Code to reproduce:
import java.io.*; 
  
public class test29 { 
    public static void main(String args[]) throws Exception { 
	File f1 = new File("a");
	File f2 = new File("a/");
	File f3 = new File("a\\");
	File f4 = new File("aa/");
        System.out.println("f1 name: " + f1.getName() + "\nf2 name: " + f2.getName() + "\nf3
name: " + f3.getName() + "\nf4 name: " + f4.getName()); 
	System.out.println(f1.equals(f2) ? "PASSED" : "FAILED");
    } 
}

Steps to Reproduce: 
1. Build Harmony (check-out on 2006-01-25) j2se subset as described in README.txt. 
2. Compile test29.java using BEA 1.4 javac 
> javac -d . test29.java 
3. Run java using compatible VM (J9) 
> java -showversion test29


Output:
C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29
java version 1.4.2 (subset)

(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.
f1 name: a
f2 name:
f3 name:
f4 name: aa
FAILED

C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
BEA WebLogic JRockit(TM) 1.4.2_04 JVM  (build ari-31788-20040616-1132-win-ia32, Native Threads,
GC strategy: parallel)

f1 name: a
f2 name: a
f3 name: a
f4 name: aa
PASSED

C:\tmp\tmp17>


junit test:
------------------------ FileTest.java -------------------------------------------------

import java.io.*; 

import junit.framework.*; 
  
public class FileTest extends TestCase { 
    public void testFile_String() { 
	File f1 = new File("a");
	File f2 = new File("a/");
	assertTrue("File name is incorrect! " + f1.getName() + " != " + f2.getName(), f1.equals(f2));
    } 

   public static void main(String[] args) { 
        junit.textui.TestRunner.run(FileTest.class); 
   } 
}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message