langtools/test/tools/javac/api/T6419926.java
author jjg
Wed, 29 Oct 2014 17:25:23 -0700
changeset 27319 030080f03e4f
parent 8039 c18afa526531
child 30730 d3ce7619db2c
permissions -rw-r--r--
8062348: langtools tests should close file manager (group 1) Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8039
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     1
/*
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
     2
 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
8039
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     4
 *
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     8
 *
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    13
 * accompanied this code).
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    14
 *
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    18
 *
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    21
 * questions.
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    22
 */
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    23
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    24
/*
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    25
 * @test
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    26
 * @bug     6419926
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    27
 * @summary JSR 199: FileObject.toUri() generates URI without schema (Solaris)
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    28
 */
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    29
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    30
import java.io.*;
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    31
import java.net.*;
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    32
import java.util.*;
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    33
import javax.tools.*;
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    34
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    35
public class T6419926 {
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    36
    public static void main(String[] argv) throws Exception {
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    37
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    38
        try (StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null)) {
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    39
            System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    40
            mgr.setLocation(StandardLocation.CLASS_OUTPUT,
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    41
                                Collections.singleton(new File(".")));
8039
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    42
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    43
            FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    44
                                    "", "file.to.delete", null);
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    45
            URI uri = fo.toUri();
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    46
            System.out.println( uri );
8039
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    47
27319
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    48
            if (!"file".equals(uri.getScheme()))
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    49
                throw new Exception("unexpected scheme for uri: " + uri.getScheme());
030080f03e4f 8062348: langtools tests should close file manager (group 1)
jjg
parents: 8039
diff changeset
    50
        }
8039
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    51
    }
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    52
}