Path: blob/master/test/langtools/tools/sjavac/HiddenFiles.java
41144 views
/*1* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 814422626* @summary Ensures that excluded files are inaccessible (even for implicit27* compilation)28* @modules jdk.compiler/com.sun.tools.javac.main29* jdk.compiler/com.sun.tools.sjavac30* jdk.compiler/com.sun.tools.sjavac.server31* @library /tools/lib32* @build Wrapper toolbox.ToolBox toolbox.Assert33* @run main Wrapper HiddenFiles34*/353637import java.nio.file.Files;38import java.nio.file.Path;39import java.nio.file.Paths;4041import com.sun.tools.javac.main.Main.Result;4243import toolbox.Assert;4445public class HiddenFiles extends SjavacBase {4647public static void main(String[] ignore) throws Exception {48Path BIN = Paths.get("bin");49Path STATE_DIR = Paths.get("state-dir");50Path SRC = Paths.get("src");5152Files.createDirectories(BIN);53Files.createDirectories(STATE_DIR);5455toolbox.writeJavaFiles(SRC, "package pkg; class A { B b; }");56toolbox.writeJavaFiles(SRC, "package pkg; class B { }");5758// This compilation should fail (return RC_FATAL) since A.java refers to B.java and B.java59// is excluded.60int rc = compile("-x", "pkg/B.java", SRC.toString(),61"-d", BIN.toString(),62"--state-dir=" + STATE_DIR);6364Assert.check(rc == Result.ERROR.exitCode, "Compilation succeeded unexpectedly.");65}66}676869