jjg@151: /* ohair@554: * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. jjg@151: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@151: * jjg@151: * This code is free software; you can redistribute it and/or modify it jjg@151: * under the terms of the GNU General Public License version 2 only, as jjg@151: * published by the Free Software Foundation. jjg@151: * jjg@151: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@151: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@151: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@151: * version 2 for more details (a copy is included in the LICENSE file that jjg@151: * accompanied this code). jjg@151: * jjg@151: * You should have received a copy of the GNU General Public License version jjg@151: * 2 along with this work; if not, write to the Free Software Foundation, jjg@151: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@151: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@151: */ jjg@151: jjg@151: /* jjg@151: * @test jjg@151: * @bug 6759996 jjg@151: * @summary javac should ignore empty entries on paths jjg@151: */ jjg@151: jjg@151: import java.io.File; jjg@151: import java.io.FileWriter; jjg@151: import java.io.IOException; jjg@151: import java.io.PrintWriter; jjg@151: import java.io.StringWriter; jjg@151: import java.io.Writer; jjg@151: jjg@151: public class T6759996 { jjg@151: public static void main(String[] args) throws Exception { jjg@151: new T6759996().run(); jjg@151: } jjg@151: jjg@151: void run() throws IOException, InterruptedException { jjg@151: String PS = File.pathSeparator; jjg@151: write(new File("A.java"), "class A { }"); jjg@151: write(new File("B.java"), "class B extends A { }"); jjg@151: // In the following line, the presence of the empty element jjg@151: // should not mask the presence of the "." element on the path jjg@151: javac("-verbose", "-sourcepath", "" + PS + ".", "B.java"); jjg@151: } jjg@151: jjg@151: void javac(String... args) throws IOException, InterruptedException { jjg@151: StringWriter sw = new StringWriter(); jjg@151: PrintWriter out = new PrintWriter(sw); jjg@151: int rc = com.sun.tools.javac.Main.compile(args, out); jjg@151: System.out.println(sw.toString()); jjg@151: if (rc != 0) jjg@151: throw new Error("javac failed: rc=" + rc); jjg@151: jjg@151: } jjg@151: jjg@151: void write(File to, String body) throws IOException { jjg@151: System.err.println("write " + to); jjg@151: File toDir = to.getParentFile(); jjg@151: if (toDir != null) { jjg@151: boolean ok = toDir.mkdirs(); jjg@151: if (!ok) { jjg@151: throw new Error("could not create directory " + toDir); jjg@151: } jjg@151: } jjg@151: Writer out = new FileWriter(to); jjg@151: try { jjg@151: out.write(body); jjg@151: if (!body.endsWith("\n")) jjg@151: out.write("\n"); jjg@151: } finally { jjg@151: out.close(); jjg@151: } jjg@151: } jjg@151: }