author | apetcher |
Thu, 07 Jun 2018 13:59:53 -0400 | |
branch | JDK-8145252-TLS13-branch |
changeset 56697 | 2dc6efcdeb11 |
parent 47398 | 1fd27535bc57 |
permissions | -rw-r--r-- |
47398
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
1 |
/* |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
4 |
* |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
10 |
* |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
15 |
* accompanied this code). |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
16 |
* |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
20 |
* |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
23 |
* questions. |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
24 |
*/ |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
25 |
package build.tools.depend; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
26 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
27 |
import com.sun.source.util.Plugin; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
28 |
import java.io.File; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
29 |
import java.io.IOException; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
30 |
import java.io.OutputStream; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
31 |
import java.net.URI; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
32 |
import java.net.URISyntaxException; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
33 |
import java.nio.file.Files; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
34 |
import java.nio.file.Path; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
35 |
import java.nio.file.Paths; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
36 |
import java.util.Arrays; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
37 |
import java.util.List; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
38 |
import javax.tools.JavaCompiler; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
39 |
import javax.tools.SimpleJavaFileObject; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
40 |
import javax.tools.ToolProvider; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
41 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
42 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
43 |
public class DependTest { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
44 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
45 |
public static void main(String... args) throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
46 |
DependTest test = new DependTest(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
47 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
48 |
test.setupClass(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
49 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
50 |
test.testMethods(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
51 |
test.testFields(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
52 |
test.testModules(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
53 |
test.testAnnotations(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
54 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
55 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
56 |
public void testMethods() throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
57 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
58 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
59 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
60 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
61 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
62 |
" public void test() {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
63 |
" }\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
64 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
65 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
66 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
67 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
68 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
69 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
70 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
71 |
" private void test() {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
72 |
" }\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
73 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
74 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
75 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
76 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
77 |
" public void test() {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
78 |
" }\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
79 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
80 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
81 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
82 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
83 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
84 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
85 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
86 |
" private void test() {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
87 |
" }\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
88 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
89 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
90 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
91 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
92 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
93 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
94 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
95 |
public void testFields() throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
96 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
97 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
98 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
99 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
100 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
101 |
" public int test;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
102 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
103 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
104 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
105 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
106 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
107 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
108 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
109 |
" private int test;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
110 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
111 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
112 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
113 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
114 |
" public static final int test = 0;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
115 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
116 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
117 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
118 |
" public static final int test = 1;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
119 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
120 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
121 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
122 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
123 |
" public int test;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
124 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
125 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
126 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
127 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
128 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
129 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
130 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
131 |
" private int test;\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
132 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
133 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
134 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
135 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
136 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
137 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
138 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
139 |
public void testAnnotations() throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
140 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
141 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
142 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
143 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
144 |
"@SuppressWarnings(\"any\")\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
145 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
146 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
147 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
148 |
doOrdinaryTest("package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
149 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
150 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
151 |
"package test;" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
152 |
"@Deprecated\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
153 |
"public class Test {\n" + |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
154 |
"}", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
155 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
156 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
157 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
158 |
public void testModules() throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
159 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
160 |
"module m { requires java.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
161 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
162 |
doModuleTest("module m { requires java.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
163 |
"module m { requires java.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
164 |
false); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
165 |
doModuleTest("module m { requires java.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
166 |
"module m { requires jdk.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
167 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
168 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
169 |
"module m { exports test; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
170 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
171 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
172 |
"module m { exports test to java.base; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
173 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
174 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
175 |
"module m { exports test to java.compiler; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
176 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
177 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
178 |
"module m { uses test.Test1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
179 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
180 |
doModuleTest("module m { uses test.Test1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
181 |
"module m { uses test.Test2; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
182 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
183 |
doModuleTest("module m { }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
184 |
"module m { provides test.Test1 with test.TestImpl1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
185 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
186 |
doModuleTest("module m { provides test.Test1 with test.TestImpl1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
187 |
"module m { provides test.Test2 with test.TestImpl1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
188 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
189 |
doModuleTest("module m { provides test.Test1 with test.TestImpl1; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
190 |
"module m { provides test.Test1 with test.TestImpl2; }", |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
191 |
true); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
192 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
193 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
194 |
private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
195 |
private Path depend; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
196 |
private Path scratchServices; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
197 |
private Path scratchClasses; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
198 |
private Path apiHash; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
199 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
200 |
private void setupClass() throws IOException { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
201 |
depend = Paths.get(Depend.class.getProtectionDomain().getCodeSource().getLocation().getPath()); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
202 |
Path scratch = Files.createTempDirectory("depend-test"); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
203 |
scratchServices = scratch.resolve("services"); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
204 |
Path scratchClassesServices = scratchServices.resolve("META-INF").resolve("services"); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
205 |
Files.createDirectories(scratchClassesServices); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
206 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
207 |
try (OutputStream out = Files.newOutputStream(scratchClassesServices.resolve(Plugin.class.getName()))) { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
208 |
out.write(Depend.class.getName().getBytes()); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
209 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
210 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
211 |
scratchClasses = scratch.resolve("classes"); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
212 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
213 |
Files.createDirectories(scratchClasses); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
214 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
215 |
apiHash = scratch.resolve("api"); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
216 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
217 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
218 |
private void doOrdinaryTest(String codeBefore, String codeAfter, boolean hashChangeExpected) throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
219 |
List<String> options = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
220 |
Arrays.asList("-d", scratchClasses.toString(), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
221 |
"-processorpath", depend.toString() + File.pathSeparator + scratchServices.toString(), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
222 |
"-Xplugin:depend " + apiHash.toString()); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
223 |
List<TestJavaFileObject> beforeFiles = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
224 |
Arrays.asList(new TestJavaFileObject("module-info", "module m { exports test; }"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
225 |
new TestJavaFileObject("test.Test", codeBefore)); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
226 |
compiler.getTask(null, null, null, options, null, beforeFiles).call(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
227 |
byte[] originalHash = Files.readAllBytes(apiHash); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
228 |
List<TestJavaFileObject> afterFiles = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
229 |
Arrays.asList(new TestJavaFileObject("module-info", "module m { exports test; }"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
230 |
new TestJavaFileObject("test.Test", codeAfter)); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
231 |
compiler.getTask(null, null, null, options, null, afterFiles).call(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
232 |
byte[] newHash = Files.readAllBytes(apiHash); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
233 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
234 |
if (Arrays.equals(originalHash, newHash) ^ !hashChangeExpected) { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
235 |
throw new AssertionError("Unexpected hash state."); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
236 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
237 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
238 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
239 |
private void doModuleTest(String codeBefore, String codeAfter, boolean hashChangeExpected) throws Exception { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
240 |
List<String> options = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
241 |
Arrays.asList("-d", scratchClasses.toString(), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
242 |
"-processorpath", depend.toString() + File.pathSeparator + scratchServices.toString(), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
243 |
"-Xplugin:depend " + apiHash.toString()); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
244 |
List<TestJavaFileObject> beforeFiles = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
245 |
Arrays.asList(new TestJavaFileObject("module-info", codeBefore), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
246 |
new TestJavaFileObject("test.Test1", "package test; public interface Test1 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
247 |
new TestJavaFileObject("test.Test2", "package test; public interface Test2 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
248 |
new TestJavaFileObject("test.TestImpl1", "package test; public class TestImpl1 implements Test1, Test2 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
249 |
new TestJavaFileObject("test.TestImpl2", "package test; public class TestImpl2 implements Test1, Test2 {}")); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
250 |
compiler.getTask(null, null, null, options, null, beforeFiles).call(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
251 |
byte[] originalHash = Files.readAllBytes(apiHash); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
252 |
List<TestJavaFileObject> afterFiles = |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
253 |
Arrays.asList(new TestJavaFileObject("module-info", codeAfter), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
254 |
new TestJavaFileObject("test.Test1", "package test; public interface Test1 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
255 |
new TestJavaFileObject("test.Test2", "package test; public interface Test2 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
256 |
new TestJavaFileObject("test.TestImpl1", "package test; public class TestImpl1 implements Test1, Test2 {}"), |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
257 |
new TestJavaFileObject("test.TestImpl2", "package test; public class TestImpl2 implements Test1, Test2 {}")); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
258 |
compiler.getTask(null, null, null, options, null, afterFiles).call(); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
259 |
byte[] newHash = Files.readAllBytes(apiHash); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
260 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
261 |
if (Arrays.equals(originalHash, newHash) ^ !hashChangeExpected) { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
262 |
throw new AssertionError("Unexpected hash state."); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
263 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
264 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
265 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
266 |
private static final class TestJavaFileObject extends SimpleJavaFileObject { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
267 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
268 |
private final String code; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
269 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
270 |
public TestJavaFileObject(String className, String code) throws URISyntaxException { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
271 |
super(new URI("mem:/" + className.replace('.', '/') + ".java"), Kind.SOURCE); |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
272 |
this.code = code; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
273 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
274 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
275 |
@Override |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
276 |
public CharSequence getCharContent(boolean arg0) throws IOException { |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
277 |
return code; |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
278 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
279 |
|
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
280 |
} |
1fd27535bc57
8182285: Speeding up incremental build by hashing module APIs
erikj
parents:
diff
changeset
|
281 |
} |