399N/A/*
553N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
399N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
399N/A *
399N/A * This code is free software; you can redistribute it and/or modify it
399N/A * under the terms of the GNU General Public License version 2 only, as
399N/A * published by the Free Software Foundation.
399N/A *
399N/A * This code is distributed in the hope that it will be useful, but WITHOUT
399N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
399N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
399N/A * version 2 for more details (a copy is included in the LICENSE file that
399N/A * accompanied this code).
399N/A *
399N/A * You should have received a copy of the GNU General Public License version
399N/A * 2 along with this work; if not, write to the Free Software Foundation,
399N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
399N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
399N/A */
399N/A
399N/A/*
399N/A * @test
399N/A * @bug 6483788
399N/A * @summary DefaultFileManager.ZipFileObject.toUri() fails to escape space characters
399N/A */
399N/A
399N/Aimport java.io.*;
399N/Aimport java.net.*;
399N/Aimport java.util.Collections;
399N/Aimport java.util.jar.*;
399N/Aimport java.util.zip.*;
399N/Aimport javax.tools.*;
399N/A
399N/Apublic class T6483788 {
399N/A public static void main(String[] args) throws Exception {
399N/A new T6483788().run();
399N/A }
399N/A
399N/A void run() throws Exception {
399N/A File jar = createJar();
399N/A JavaCompiler c = ToolProvider.getSystemJavaCompiler();
399N/A StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
399N/A fm.setLocation(StandardLocation.CLASS_PATH, Collections.singleton(jar));
399N/A JavaFileObject fo = fm.getJavaFileForInput(StandardLocation.CLASS_PATH, "dummy", JavaFileObject.Kind.CLASS);
399N/A System.err.println("file: " + fo);
399N/A URI uri = fo.toUri();
399N/A System.err.println("uri: " + uri);
399N/A if (uri.toString().contains(" "))
399N/A throw new Exception("unexpected space character found");
399N/A }
399N/A
399N/A File createJar() throws IOException {
399N/A byte[] dummy_data = new byte[10];
399N/A File f = new File("a b.jar");
399N/A OutputStream out = new FileOutputStream(f);
399N/A try {
399N/A JarOutputStream jar = new JarOutputStream(out);
399N/A jar.putNextEntry(new ZipEntry("dummy.class"));
399N/A jar.write(dummy_data);
399N/A jar.close();
399N/A } finally {
399N/A out.close();
399N/A }
399N/A return f;
399N/A }
399N/A}
399N/A