harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [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.
Date Tue, 20 Feb 2007 14:11:05 GMT

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

View raw message