Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/tools/sjavac/IncCompileWithChanges.java
41144 views
1
/*
2
* Copyright (c) 2014, 2016, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @summary Verify incremental changes in gensrc are handled as expected
27
* @bug 8054689
28
* @author Fredrik O
29
* @author sogoel (rewrite)
30
* @library /tools/lib
31
* @modules jdk.compiler/com.sun.tools.javac.api
32
* jdk.compiler/com.sun.tools.javac.main
33
* jdk.compiler/com.sun.tools.sjavac
34
* @ignore Requires dependency code to deal with in-method dependencies.
35
* @build Wrapper toolbox.ToolBox
36
* @run main Wrapper IncCompileWithChanges
37
*/
38
39
import java.util.*;
40
import java.nio.file.*;
41
42
import toolbox.ToolBox;
43
44
public class IncCompileWithChanges extends SJavacTester {
45
public static void main(String... args) throws Exception {
46
IncCompileWithChanges wc = new IncCompileWithChanges();
47
wc.test();
48
}
49
50
// Remember the previous bin and headers state here.
51
Map<String,Long> previous_bin_state;
52
Map<String,Long> previous_headers_state;
53
54
void test() throws Exception {
55
clean(TEST_ROOT);
56
Files.createDirectories(GENSRC);
57
Files.createDirectories(BIN);
58
Files.createDirectories(HEADERS);
59
60
initialCompile();
61
incrementalCompileWithChange();
62
}
63
64
/* Update A.java with a new timestamp and new final static definition.
65
* This should trigger a recompile, not only of alfa, but also beta.
66
* Generated native header should not be updated since native api of B was not modified.
67
*/
68
void incrementalCompileWithChange() throws Exception {
69
previous_bin_state = collectState(BIN);
70
previous_headers_state = collectState(HEADERS);
71
System.out.println("\nIn incrementalCompileWithChange() ");
72
System.out.println("A.java updated to trigger a recompile");
73
System.out.println("Generated native header should not be updated since native api of B was not modified");
74
tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
75
"package alfa.omega; public class A implements AINT { " +
76
"public final static int DEFINITION = 18;" +
77
"public void aint() { } private void foo() { } }");
78
79
compile(GENSRC.toString(),
80
"-d", BIN.toString(),
81
"--state-dir=" + BIN,
82
"-h", HEADERS.toString(),
83
"-j", "1",
84
"--log=debug");
85
Map<String,Long> new_bin_state = collectState(BIN);
86
87
verifyNewerFiles(previous_bin_state, new_bin_state,
88
BIN + "/alfa/omega/A.class",
89
BIN + "/alfa/omega/AINT.class",
90
BIN + "/alfa/omega/AA$AAAA.class",
91
BIN + "/alfa/omega/AAAAA.class",
92
BIN + "/alfa/omega/AA$AAA.class",
93
BIN + "/alfa/omega/AA.class",
94
BIN + "/alfa/omega/AA$1.class",
95
BIN + "/beta/B.class",
96
BIN + "/beta/BINT.class",
97
BIN + "/javac_state");
98
previous_bin_state = new_bin_state;
99
100
Map<String,Long> new_headers_state = collectState(HEADERS);
101
verifyEqual(new_headers_state, previous_headers_state);
102
}
103
}
104
105