IncCompileFullyQualifiedRef.java revision 3573:c4a18ee691c4
1314125Sdelphij/*
2290207Sjkim * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3290207Sjkim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4290207Sjkim *
5290207Sjkim * This code is free software; you can redistribute it and/or modify it
6290207Sjkim * under the terms of the GNU General Public License version 2 only, as
7290207Sjkim * published by the Free Software Foundation.
8290207Sjkim *
9290207Sjkim * This code is distributed in the hope that it will be useful, but WITHOUT
10290207Sjkim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11290207Sjkim * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12290207Sjkim * version 2 for more details (a copy is included in the LICENSE file that
13290207Sjkim * accompanied this code).
14290207Sjkim *
15290207Sjkim * You should have received a copy of the GNU General Public License version
16290207Sjkim * 2 along with this work; if not, write to the Free Software Foundation,
17290207Sjkim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18290207Sjkim *
19290207Sjkim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20290207Sjkim * or visit www.oracle.com if you need additional information or have any
21290207Sjkim * questions.
22290207Sjkim */
23290207Sjkim
24290207Sjkim/*
25290207Sjkim * @test
26290207Sjkim * @summary Verify that "alfa.omega.A a" does create a proper dependency
27290207Sjkim * @bug 8054689
28290207Sjkim * @author Fredrik O
29290207Sjkim * @author sogoel (rewrite)
30290207Sjkim * @library /tools/lib
31290207Sjkim * @modules jdk.compiler/com.sun.tools.javac.api
32290207Sjkim *          jdk.compiler/com.sun.tools.javac.main
33290207Sjkim *          jdk.compiler/com.sun.tools.sjavac
34290207Sjkim * @ignore Requires dependency code to deal with in-method dependencies.
35290207Sjkim * @build Wrapper toolbox.ToolBox
36290207Sjkim * @run main Wrapper IncCompileFullyQualifiedRef
37290207Sjkim */
38290207Sjkim
39290207Sjkimimport java.util.Map;
40290207Sjkim
41290207Sjkimimport toolbox.ToolBox;
42290207Sjkim
43290207Sjkimpublic class IncCompileFullyQualifiedRef extends SJavacTester {
44290207Sjkim    public static void main(String... args) throws Exception {
45290207Sjkim        IncCompileFullyQualifiedRef fr = new IncCompileFullyQualifiedRef();
46290207Sjkim        fr.test();
47290207Sjkim    }
48290207Sjkim
49314125Sdelphij    void test() throws Exception {
50290207Sjkim        clean(TEST_ROOT);
51290207Sjkim        tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
52290207Sjkim                     "package alfa.omega; public class A { "+
53290207Sjkim                     "  public final static int DEFINITION = 18; "+
54290207Sjkim                     "  public void hello() { }"+
55290207Sjkim                     "}");
56290207Sjkim        tb.writeFile(GENSRC.resolve("beta/B.java"),
57314125Sdelphij                     "package beta; public class B { "+
58314125Sdelphij                     "  public void world() { alfa.omega.A a; }"+
59314125Sdelphij                     "}");
60314125Sdelphij
61290207Sjkim        compile(GENSRC.toString(),
62314125Sdelphij                "-d", BIN.toString(),
63314125Sdelphij                "--state-dir=" + BIN,
64314125Sdelphij                "-j", "1",
65290207Sjkim                "--log=debug");
66290207Sjkim        Map<String,Long> previous_bin_state = collectState(BIN);
67290207Sjkim
68290207Sjkim        // Change pubapi of A, this should trigger a recompile of B.
69290207Sjkim        tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
70290207Sjkim                     "package alfa.omega; public class A { "+
71290207Sjkim                     "  public final static int DEFINITION = 19; "+
72290207Sjkim                     "  public void hello() { }"+
73290207Sjkim                     "}");
74290207Sjkim
75290207Sjkim        compile(GENSRC.toString(),
76290207Sjkim                "-d", BIN.toString(),
77290207Sjkim                "--state-dir=" + BIN,
78290207Sjkim                "-j", "1",
79290207Sjkim                "--log=debug");
80290207Sjkim        Map<String,Long> new_bin_state = collectState(BIN);
81290207Sjkim
82290207Sjkim        verifyNewerFiles(previous_bin_state, new_bin_state,
83290207Sjkim                         BIN + "/alfa/omega/A.class",
84290207Sjkim                         BIN + "/beta/B.class",
85290207Sjkim                         BIN + "/javac_state");
86290207Sjkim        clean(GENSRC,BIN);
87290207Sjkim    }
88290207Sjkim}
89290207Sjkim