The following example program gives different results on 1.2beta4 and 1.2beta3, 1.1.6 etc.
import java.io.File;
public class GetPath {
public static void main(String args[]) {
File f = new File("foo" + File.separatorChar);
System.out.println("File(\"foo" + File.separatorChar + "\")" +
" getPath() = " + f.getPath());
}
}
1.2beta4 - File("foo/") getPath() = foo
1.2beta3 - File("foo/") getPath() = foo/
1.1.6 - File("foo/") getPath() = foo/
In 1.2beta4, if a trailing File.separatorChar is used in the File constructor, it is not returned in File.getPath(). While in 1.2beta3 and 1.1.6 the trailing File.separatorChar is returned.
This is not a bug really, but could break user's code which depended on this behaviour. SpecJava _213_javac broke with this change. To maintain compatibility it might be a good idea to return the trailing File.separatorChar.
- duplicates
-
JDK-4208417 java.io.File.getAbsolutePath with null path does not return trailing slash
-
- Closed
-
- relates to
-
JDK-4131169 java.io.File: Respecify using abstract pathnames rather than strings
-
- Closed
-