langtools/test/tools/javac/T6759996.java
author katleman
Thu, 21 Aug 2014 14:16:14 -0700
changeset 25878 6d561031123e
parent 5520 86e4b9a9da40
child 30730 d3ce7619db2c
permissions -rw-r--r--
Added tag jdk9-b27 for changeset 98ce0879ab4c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1486
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1486
diff changeset
     2
 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
1486
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     4
 *
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     8
 *
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    13
 * accompanied this code).
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    14
 *
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1486
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1486
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1486
diff changeset
    21
 * questions.
1486
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    22
 */
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    23
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    24
/*
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    25
 * @test
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    26
 * @bug 6759996
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    27
 * @summary javac should ignore empty entries on paths
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    28
 */
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    29
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    30
import java.io.File;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    31
import java.io.FileWriter;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    32
import java.io.IOException;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    33
import java.io.PrintWriter;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    34
import java.io.StringWriter;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    35
import java.io.Writer;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    36
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    37
public class T6759996 {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    39
        new T6759996().run();
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    40
    }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    41
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    42
    void run() throws IOException, InterruptedException {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    43
        String PS = File.pathSeparator;
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    44
        write(new File("A.java"), "class A { }");
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    45
        write(new File("B.java"), "class B extends A { }");
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    46
        // In the following line, the presence of the empty element
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    47
        // should not mask the presence of the "." element on the path
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    48
        javac("-verbose", "-sourcepath", "" + PS + ".", "B.java");
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    49
    }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    50
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    51
    void javac(String... args) throws IOException, InterruptedException {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    52
        StringWriter sw = new StringWriter();
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    53
        PrintWriter out = new PrintWriter(sw);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    54
        int rc = com.sun.tools.javac.Main.compile(args, out);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    55
        System.out.println(sw.toString());
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    56
        if (rc != 0)
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    57
            throw new Error("javac failed: rc=" + rc);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    58
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    59
    }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    60
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    61
    void write(File to, String body) throws IOException {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    62
        System.err.println("write " + to);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    63
        File toDir = to.getParentFile();
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    64
        if (toDir != null) {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    65
            boolean ok = toDir.mkdirs();
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    66
            if (!ok) {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    67
                throw new Error("could not create directory " + toDir);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    68
            }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    69
        }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    70
        Writer out = new FileWriter(to);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    71
        try {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    72
            out.write(body);
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    73
            if (!body.endsWith("\n"))
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    74
                out.write("\n");
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    75
        } finally {
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    76
            out.close();
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    77
        }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    78
    }
a7d1338ca96e 6759996: ignore empty entries on paths
jjg
parents:
diff changeset
    79
}