You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Elena Semukhina (JIRA)" <ji...@apache.org> on 2007/02/20 12:57:06 UTC

[jira] Created: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

[classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
--------------------------------------------------------------------------------------------------------

                 Key: HARMONY-3207
                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Elena Semukhina


The spec for File.toURI() reads:
"If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
The spec says the same for File.toURL().

The following test shows up a case when this does not work properly:

import java.io.*;
import java.net.URL;
import java.net.URI;

public class TestToURI {

	public static void main(String args[]) {
		File f = new File("");

		try {
			URI uri = f.toURI();
			URL url = f.toURL();
			System.out.println("URI = " + uri); 
			System.out.println("URL = " + url); 
		}
		catch (Exception e) {
		} 
	}
}

Output on RI:

C:\users\esemukhi\test\lang>java -showversion TestToURI
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)

URI = file:/C:/users/esemukhi/test/lang/
URL = file:/C:/users/esemukhi/test/lang

Output on DRLVM:

C:\users\esemukhi\test\lang>java -showversion TestToURI
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
n or its licensors, as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
http://incubator.apache.org/harmony
URI = file:/C:/users/esemukhi/test/lang
URL = file:/C:/users/esemukhi/test/lang

File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.

This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

Posted by "Elena Semukhina (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12474919 ] 

Elena Semukhina commented on HARMONY-3207:
------------------------------------------

I tried the patch. It works as expected. Both URI and URL end up with a slash now.
Thanks for the prompt fix!



> [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3207
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Semukhina
>         Attachments: H-3207.patch
>
>
> The spec for File.toURI() reads:
> "If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
> The spec says the same for File.toURL().
> The following test shows up a case when this does not work properly:
> import java.io.*;
> import java.net.URL;
> import java.net.URI;
> public class TestToURI {
> 	public static void main(String args[]) {
> 		File f = new File("");
> 		try {
> 			URI uri = f.toURI();
> 			URL url = f.toURL();
> 			System.out.println("URI = " + uri); 
> 			System.out.println("URL = " + url); 
> 		}
> 		catch (Exception e) {
> 		} 
> 	}
> }
> Output on RI:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> java version "1.5.0_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)
> URI = file:/C:/users/esemukhi/test/lang/
> URL = file:/C:/users/esemukhi/test/lang
> Output on DRLVM:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
> n or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> URI = file:/C:/users/esemukhi/test/lang
> URL = file:/C:/users/esemukhi/test/lang
> File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.
> This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-3207:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3207
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Semukhina
>         Assigned To: Alexei Zakharov
>         Attachments: H-3207.patch
>
>
> The spec for File.toURI() reads:
> "If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
> The spec says the same for File.toURL().
> The following test shows up a case when this does not work properly:
> import java.io.*;
> import java.net.URL;
> import java.net.URI;
> public class TestToURI {
> 	public static void main(String args[]) {
> 		File f = new File("");
> 		try {
> 			URI uri = f.toURI();
> 			URL url = f.toURL();
> 			System.out.println("URI = " + uri); 
> 			System.out.println("URL = " + url); 
> 		}
> 		catch (Exception e) {
> 		} 
> 	}
> }
> Output on RI:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> java version "1.5.0_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)
> URI = file:/C:/users/esemukhi/test/lang/
> URL = file:/C:/users/esemukhi/test/lang
> Output on DRLVM:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
> n or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> URI = file:/C:/users/esemukhi/test/lang
> URL = file:/C:/users/esemukhi/test/lang
> File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.
> This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-3207.
--------------------------------------

    Resolution: Fixed

Thanks Elena and Mikhail. I've applied the patch at the revision 513774. Please verify.

> [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3207
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Semukhina
>         Assigned To: Alexei Zakharov
>         Attachments: H-3207.patch
>
>
> The spec for File.toURI() reads:
> "If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
> The spec says the same for File.toURL().
> The following test shows up a case when this does not work properly:
> import java.io.*;
> import java.net.URL;
> import java.net.URI;
> public class TestToURI {
> 	public static void main(String args[]) {
> 		File f = new File("");
> 		try {
> 			URI uri = f.toURI();
> 			URL url = f.toURL();
> 			System.out.println("URI = " + uri); 
> 			System.out.println("URL = " + url); 
> 		}
> 		catch (Exception e) {
> 		} 
> 	}
> }
> Output on RI:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> java version "1.5.0_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)
> URI = file:/C:/users/esemukhi/test/lang/
> URL = file:/C:/users/esemukhi/test/lang
> Output on DRLVM:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
> n or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> URI = file:/C:/users/esemukhi/test/lang
> URL = file:/C:/users/esemukhi/test/lang
> File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.
> This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov updated HARMONY-3207:
-------------------------------------

    Patch Info: [Patch Available]

> [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3207
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Semukhina
>         Attachments: H-3207.patch
>
>
> The spec for File.toURI() reads:
> "If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
> The spec says the same for File.toURL().
> The following test shows up a case when this does not work properly:
> import java.io.*;
> import java.net.URL;
> import java.net.URI;
> public class TestToURI {
> 	public static void main(String args[]) {
> 		File f = new File("");
> 		try {
> 			URI uri = f.toURI();
> 			URL url = f.toURL();
> 			System.out.println("URI = " + uri); 
> 			System.out.println("URL = " + url); 
> 		}
> 		catch (Exception e) {
> 		} 
> 	}
> }
> Output on RI:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> java version "1.5.0_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)
> URI = file:/C:/users/esemukhi/test/lang/
> URL = file:/C:/users/esemukhi/test/lang
> Output on DRLVM:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
> n or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> URI = file:/C:/users/esemukhi/test/lang
> URL = file:/C:/users/esemukhi/test/lang
> File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.
> This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-3207) [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-3207:
------------------------------------

    Attachment: H-3207.patch

Here is the patch and regression test.

Fix description: i've fixed both toURI() & toURL() methods by calling getAbsoluteFile().isDirectory() instead of simple isDirectory() call for proper directory checking as according to API spec: "If the given string is the empty string, then the result is the empty abstract pathname." and isDirectory() call will return false on this object.

Note, that after my fix the Harmony behaviour of toURL() method differs from RI (as was mentioned by this JIRA description - RI violates the spec for toURL() method). Perhaps it makes sense to file non-bug difference against RI with won't fix resolution.

> [classlib][io] File.toURI does not add a slash at the end of URI for a directory pathname in some cases.
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3207
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3207
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Elena Semukhina
>         Attachments: H-3207.patch
>
>
> The spec for File.toURI() reads:
> "If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash."
> The spec says the same for File.toURL().
> The following test shows up a case when this does not work properly:
> import java.io.*;
> import java.net.URL;
> import java.net.URI;
> public class TestToURI {
> 	public static void main(String args[]) {
> 		File f = new File("");
> 		try {
> 			URI uri = f.toURI();
> 			URL url = f.toURL();
> 			System.out.println("URI = " + uri); 
> 			System.out.println("URL = " + url); 
> 		}
> 		catch (Exception e) {
> 		} 
> 	}
> }
> Output on RI:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> java version "1.5.0_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode)
> URI = file:/C:/users/esemukhi/test/lang/
> URL = file:/C:/users/esemukhi/test/lang
> Output on DRLVM:
> C:\users\esemukhi\test\lang>java -showversion TestToURI
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio
> n or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509434, (Feb 20 2007), Windows/ia32/msvc 1310, debug build
> http://incubator.apache.org/harmony
> URI = file:/C:/users/esemukhi/test/lang
> URL = file:/C:/users/esemukhi/test/lang
> File.toURL() does not work according to spec on RI as well. If we want to be compatible to RI, we should fix toURI() at least.
> This affects the behavior of java.net.URLClassloader which relies on the terminal slash in a URL in defining its protocol. It now specifies the protocol of the file in the test as "jar" while it should be "file".

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.