langtools/test/tools/sjavac/HiddenFiles.java
author jjg
Wed, 10 Aug 2016 15:47:46 -0700
changeset 40308 274367a99f98
parent 37643 626e07816dce
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers 8160489: Multiple -Xpatch lines ignored by javac 8156998: javac should support new option -XinheritRuntimeEnvironment Reviewed-by: jlahoda, ksrini
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     1
/*
35356
e919fd8db52c 8056989: Sjavac --server option should be optional
alundblad
parents: 34991
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     4
 *
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    10
 *
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    15
 * accompanied this code).
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    16
 *
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    20
 *
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    23
 * questions.
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    24
 */
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    25
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    26
/*
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    27
 * @test
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    28
 * @bug 8144226
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    29
 * @summary Ensures that excluded files are inaccessible (even for implicit
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    30
 *          compilation)
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    31
 * @modules jdk.compiler/com.sun.tools.javac.main
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    32
 *          jdk.compiler/com.sun.tools.sjavac
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    33
 *          jdk.compiler/com.sun.tools.sjavac.server
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    34
 * @library /tools/lib
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    35
 * @build Wrapper toolbox.ToolBox toolbox.Assert
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    36
 * @run main Wrapper HiddenFiles
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    37
 */
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    38
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    39
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    40
import java.nio.file.Files;
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    41
import java.nio.file.Path;
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    42
import java.nio.file.Paths;
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    43
40308
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    44
import com.sun.tools.javac.main.Main.Result;
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    45
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    46
import toolbox.Assert;
274367a99f98 8136930: Simplify use of module-system options by custom launchers
jjg
parents: 37643
diff changeset
    47
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    48
public class HiddenFiles extends SjavacBase {
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    49
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    50
    public static void main(String[] ignore) throws Exception {
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    51
        Path BIN = Paths.get("bin");
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    52
        Path STATE_DIR = Paths.get("state-dir");
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    53
        Path SRC = Paths.get("src");
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    54
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    55
        Files.createDirectories(BIN);
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    56
        Files.createDirectories(STATE_DIR);
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    57
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    58
        toolbox.writeJavaFiles(SRC, "package pkg; class A { B b; }");
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    59
        toolbox.writeJavaFiles(SRC, "package pkg; class B { }");
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    60
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    61
        // This compilation should fail (return RC_FATAL) since A.java refers to B.java and B.java
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    62
        // is excluded.
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    63
        int rc = compile("-x", "pkg/B.java", SRC.toString(),
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    64
                         "-d", BIN.toString(),
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    65
                         "--state-dir=" + STATE_DIR);
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    66
37643
626e07816dce 8048146: sjavac uses unexpected exit code of -1
alundblad
parents: 36778
diff changeset
    67
        Assert.check(rc == Result.ERROR.exitCode, "Compilation succeeded unexpectedly.");
34991
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    68
    }
ff8be37d1164 8144226: Sjavac's handling of include/exclude patterns is buggy, redundant and inconsistent
alundblad
parents:
diff changeset
    69
}