harmony-commits mailing list archives

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