langtools/test/tools/javac/api/6440333/T6440333.java
changeset 3782 ae62279eeb46
parent 3774 33a6953bed15
child 3890 b53fced26fa4
equal deleted inserted replaced
3781:cad98ced28c5 3782:ae62279eeb46
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug     6440333
    26  * @bug     6440333
    27  * @summary SimpleJavaFileObject.toString() generates URI with some extra message
    27  * @summary SimpleJavaFileObject.toString() generates URI with some extra message
    28  * @author  Peter von der Ah\u00e9
    28  * @author  Peter von der Ah\u00e9
    29  * @ignore 6877223 test ignored because of issues with File.toUri on Windows (6877206)
       
    30  * @library ../lib
    29  * @library ../lib
    31  * @compile T6440333.java
    30  * @compile T6440333.java
    32  * @run main T6440333
    31  * @run main T6440333
    33  */
    32  */
    34 
    33 
    35 import java.io.File;
    34 import java.io.File;
    36 import java.io.IOException;
    35 import java.io.IOException;
       
    36 import java.net.URI;
    37 import javax.tools.JavaFileObject;
    37 import javax.tools.JavaFileObject;
    38 
    38 
    39 public class T6440333 extends ToolTester {
    39 public class T6440333 extends ToolTester {
    40     void test(String... args) throws IOException {
    40     void test(String... args) throws IOException {
    41         File path = test_src.getCanonicalFile();
    41         File path = test_src.getCanonicalFile();
    42         File src = new File(new File(path, "."), "T6440333.java");
    42         File src = new File(new File(path, "."), "T6440333.java");
    43         JavaFileObject fo = fm.getJavaFileObjects(src).iterator().next();
    43         JavaFileObject fo = fm.getJavaFileObjects(src).iterator().next();
    44         String expect = src.getCanonicalFile().getPath().replace(File.separatorChar, '/');
    44         URI expect = src.getCanonicalFile().toURI();
    45         System.err.println("Expect " + expect);
    45         System.err.println("Expect " + expect);
    46         // CURRENTLY, the following line fails on Windows because a file C:/w/jjg/...
    46         System.err.println("Found  " + fo.toUri());
    47         // returns a URI file://C/w/jjg... which incorrectly encodes the drive letter
    47         if (!expect.equals(fo.toUri())) {
    48         // in the URI authority.   This is against the spec that the authority is
       
    49         // undefined and breaks the contract that new File(f.toURI()).equals(f.getAbsoluteFile())
       
    50         System.err.println("Got: " +  fo.toUri().getPath());
       
    51         if (!expect.equals(fo.toUri().getPath())) {
       
    52             throw new AssertionError();
    48             throw new AssertionError();
    53         }
    49         }
    54     }
    50     }
    55     public static void main(String... args) throws IOException {
    51     public static void main(String... args) throws IOException {
    56         new T6440333().test(args);
    52         new T6440333().test(args);