[ 
http://issues.apache.org/jira/browse/HARMONY-21?page=comments#action_12359243 ] 

Vladimir Strigun commented on HARMONY-21:
-----------------------------------------

The cause of problem is realization of fixSlashes() method of java.io.File. 
Another testcase for this bug is almost the same (but reroduced with another 
constructor):
public void test_File_Constructor() { 
File path = new File("/dir/file"); 
File file = new File("/", "dir/file"); 

assertEquals("wrong path result ", path.getPath(), file.getPath()); 
} 
I've try create the fix for the issue and I can suggest not very elegant, but 
very efficient fix for it:
254c254
<                               if ((foundSlash && i == uncIndex) || 
!foundSlash) {
---
>                               if ((foundSlash && i == uncIndex && 
> path.charAt(0) == '/' && pathChar != '\\') || !foundSlash) {
fixSlashes functions converts all slashes to default separator. So, on Windows 
it converts first '/' to '\' and after next iteration we receive UNC path 
instead of path to root folder. Additional check of first symbol fix this 
problem.

> File constructor produces wrong path to absolute path specified relative to 
> root
> --------------------------------------------------------------------------------
>
>          Key: HARMONY-21
>          URL: http://issues.apache.org/jira/browse/HARMONY-21
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Tim Ellison
>     Assignee: Geir Magnusson Jr

>
> Specifying an absolute path relative to the root directory produces the wrong 
> final pathname.
> Here's a simple test illustrating the problem:
>       public void test_File_Constructor() {
>               File path = new File("/dir/file");
>               File root = new File("/");
>               File file = new File(root, "/dir/file");
>               assertEquals("wrong path result ", path.getPath(), 
> file.getPath());
>       }

-- 
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

Reply via email to