IncCompileFullyQualifiedRef.java revision 2958:27da0c3ac83a
1/* 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26/* 27 * @test 28 * @summary Verify that "alfa.omega.A a" does create a proper dependency 29 * @bug 8054689 30 * @ignore Requires dependency code to deal with in-method dependencies. 31 * @author Fredrik O 32 * @author sogoel (rewrite) 33 * @library /tools/lib 34 * @modules jdk.compiler/com.sun.tools.javac.api 35 * jdk.compiler/com.sun.tools.javac.file 36 * jdk.compiler/com.sun.tools.javac.main 37 * jdk.compiler/com.sun.tools.sjavac 38 * @build Wrapper ToolBox 39 * @run main Wrapper IncCompileFullyQualifiedRef 40 */ 41 42import java.util.Map; 43 44public class IncCompileFullyQualifiedRef extends SJavacTester { 45 public static void main(String... args) throws Exception { 46 IncCompileFullyQualifiedRef fr = new IncCompileFullyQualifiedRef(); 47 fr.test(); 48 } 49 50 void test() throws Exception { 51 clean(TEST_ROOT); 52 ToolBox tb = new ToolBox(); 53 tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), 54 "package alfa.omega; public class A { "+ 55 " public final static int DEFINITION = 18; "+ 56 " public void hello() { }"+ 57 "}"); 58 tb.writeFile(GENSRC.resolve("beta/B.java"), 59 "package beta; public class B { "+ 60 " public void world() { alfa.omega.A a; }"+ 61 "}"); 62 63 compile(GENSRC.toString(), 64 "-d", BIN.toString(), 65 "-j", "1", 66 SERVER_ARG, 67 "--log=debug"); 68 Map<String,Long> previous_bin_state = collectState(BIN); 69 70 // Change pubapi of A, this should trigger a recompile of B. 71 tb.writeFile(GENSRC.resolve("alfa/omega/A.java"), 72 "package alfa.omega; public class A { "+ 73 " public final static int DEFINITION = 19; "+ 74 " public void hello() { }"+ 75 "}"); 76 77 compile(GENSRC.toString(), 78 "-d", BIN.toString(), 79 "-j", "1", 80 SERVER_ARG, 81 "--log=debug"); 82 Map<String,Long> new_bin_state = collectState(BIN); 83 84 verifyNewerFiles(previous_bin_state, new_bin_state, 85 BIN + "/alfa/omega/A.class", 86 BIN + "/beta/B.class", 87 BIN + "/javac_state"); 88 clean(GENSRC,BIN); 89 } 90} 91