Path: blob/master/test/langtools/tools/sjavac/PermittedArtifact.java
41144 views
/*1* Copyright (c) 2014, 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* @summary Test white listing of external artifacts inside the destination dir26* @bug 805468927* @author Fredrik O28* @author sogoel (rewrite)29* @library /tools/lib30* @modules jdk.compiler/com.sun.tools.javac.api31* jdk.compiler/com.sun.tools.javac.main32* jdk.compiler/com.sun.tools.sjavac33* @build Wrapper toolbox.ToolBox34* @run main Wrapper PermittedArtifact35*/3637import java.nio.file.Files;38import java.util.Map;3940public class PermittedArtifact extends SJavacTester {41public static void main(String... args) throws Exception {42PermittedArtifact pa = new PermittedArtifact();43pa.test();44}4546//Verify that --permit-artifact=bin works47void test() throws Exception {48Files.createDirectories(BIN);4950Map<String,Long> previous_bin_state = collectState(BIN);5152tb.writeFile(GENSRC + "/alfa/omega/A.java",53"package alfa.omega; public class A { }");5455tb.writeFile(BIN + "/alfa/omega/AA.class",56"Ugh, a messy build system (tobefixed) wrote this class file, " +57"sjavac must not delete it.");5859compile("--log=debug",60"--permit-artifact=" + BIN + "/alfa/omega/AA.class",61"-src", GENSRC.toString(),62"-d", BIN.toString(),63"--state-dir=" + BIN);6465Map<String,Long> new_bin_state = collectState(BIN);66verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state,67BIN + "/alfa/omega/A.class",68BIN + "/alfa/omega/AA.class",69BIN + "/javac_state");70}71}727374