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