langtools/test/tools/javac/api/T6419926.java
author darcy
Wed, 01 Jun 2011 23:56:31 -0700
changeset 10180 b293c1f36ac4
parent 8039 c18afa526531
child 27319 030080f03e4f
permissions -rw-r--r--
7025784: Add SourceVersion.RELEASE_8 7025786: Add -source 8 and -target 8 to javac 7025789: Change javac source and target default to 8 Reviewed-by: jjg
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
/*
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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();
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    38
        StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>(), null, null);
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    39
        System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    40
        mgr.setLocation(StandardLocation.CLASS_OUTPUT,
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    41
                            Collections.singleton(new File(".")));
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    42
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    43
        FileObject fo = mgr.getFileForOutput(StandardLocation.CLASS_OUTPUT,
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    44
                                "", "file.to.delete", null);
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    45
        URI uri = fo.toUri();
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    46
        System.out.println( uri );
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    47
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    48
        if (!"file".equals(uri.getScheme()))
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    49
            throw new Exception("unexpected scheme for uri: " + uri.getScheme());
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    50
    }
c18afa526531 6419926: JSR 199: FileObject.toUri() generates URI without schema (Solaris)
jjg
parents:
diff changeset
    51
}