FULL PRODUCT VERSION :
java version " 1.6.0_45 "
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
It is possible to build a File object with a trailing backslash in its canonical representation (returned by the method getCanonicalPath).
This trailing backslash makes the representation non-canonical (non-unique) as the same path without the trailing backslash will represent the same file but with a different representation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
File f = new File( " c:\\Program Files " );
File f2 = new File(f, " \\ " ); // problem
File f3 = new File(f, " \\.\\ " ); // resolves correctly
System.out.println(f.getCanonicalPath());
System.out.println(f2.getCanonicalPath());
System.out.println(f3.getCanonicalPath());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C:\Program Files
C:\Program Files
C:\Program Files
ACTUAL -
C:\Program Files
C:\Program FilesC:\Program Files
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.io.IOException;
/**
* TestCanonical
*
*/
public class TestCanonical {
public static void main(String[] args) throws IOException {
File f = new File( " c:\\Program Files " );
File f2 = new File(f, " \\ " ); // problem
File f3 = new File(f, " \\.\\ " ); // resolves correctly
System.out.println(f.getCanonicalPath());
System.out.println(f2.getCanonicalPath());
System.out.println(f3.getCanonicalPath());
}
}
---------- END SOURCE ----------
java version " 1.6.0_45 "
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
It is possible to build a File object with a trailing backslash in its canonical representation (returned by the method getCanonicalPath).
This trailing backslash makes the representation non-canonical (non-unique) as the same path without the trailing backslash will represent the same file but with a different representation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
File f = new File( " c:\\Program Files " );
File f2 = new File(f, " \\ " ); // problem
File f3 = new File(f, " \\.\\ " ); // resolves correctly
System.out.println(f.getCanonicalPath());
System.out.println(f2.getCanonicalPath());
System.out.println(f3.getCanonicalPath());
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
C:\Program Files
C:\Program Files
C:\Program Files
ACTUAL -
C:\Program Files
C:\Program FilesC:\Program Files
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.io.IOException;
/**
* TestCanonical
*
*/
public class TestCanonical {
public static void main(String[] args) throws IOException {
File f = new File( " c:\\Program Files " );
File f2 = new File(f, " \\ " ); // problem
File f3 = new File(f, " \\.\\ " ); // resolves correctly
System.out.println(f.getCanonicalPath());
System.out.println(f2.getCanonicalPath());
System.out.println(f3.getCanonicalPath());
}
}
---------- END SOURCE ----------