author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 40308 | langtools/test/tools/sjavac/ApiExtraction.java@274367a99f98 |
permissions | -rw-r--r-- |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
1 |
/* |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
4 |
* |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
32337 | 7 |
* published by the Free Software Foundation. |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
8 |
* |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
13 |
* accompanied this code). |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
14 |
* |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
18 |
* |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
21 |
* questions. |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
22 |
*/ |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
23 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
24 |
/* |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
25 |
* @test |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
26 |
* @bug 8054717 |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
27 |
* @summary Make sure extraction of non-private APIs work as expected. |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
28 |
* @library /tools/lib |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.sjavac |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.sjavac.options |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.sjavac.pubapi |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
34 |
* @build Wrapper toolbox.ToolBox toolbox.JavacTask |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
35 |
* @run main Wrapper ApiExtraction |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
36 |
*/ |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
37 |
|
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
38 |
import static java.util.Arrays.asList; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
39 |
import static java.util.Collections.emptyList; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
40 |
import static javax.lang.model.element.Modifier.FINAL; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
41 |
import static javax.lang.model.element.Modifier.PROTECTED; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
42 |
import static javax.lang.model.element.Modifier.PUBLIC; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
43 |
import static javax.lang.model.element.Modifier.STATIC; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
44 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
45 |
import java.io.IOException; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
46 |
import java.util.HashSet; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
47 |
import java.util.List; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
48 |
import java.util.Set; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
49 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
50 |
import javax.lang.model.type.TypeKind; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
51 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
52 |
import com.sun.tools.sjavac.PubApiExtractor; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
53 |
import com.sun.tools.sjavac.options.Options; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
54 |
import com.sun.tools.sjavac.pubapi.PrimitiveTypeDesc; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
55 |
import com.sun.tools.sjavac.pubapi.PubApi; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
56 |
import com.sun.tools.sjavac.pubapi.PubMethod; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
57 |
import com.sun.tools.sjavac.pubapi.PubType; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
58 |
import com.sun.tools.sjavac.pubapi.PubVar; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
59 |
import com.sun.tools.sjavac.pubapi.ReferenceTypeDesc; |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
60 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
61 |
import toolbox.JavacTask; |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
62 |
import toolbox.ToolBox; |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
63 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
64 |
public class ApiExtraction { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
65 |
public static void main(String[] args) throws IOException { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
66 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
67 |
String testSrc = String.join("\n", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
68 |
"import java.util.*;", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
69 |
"public final class TestClass extends Thread {", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
70 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
71 |
// Fields with various combination of modifiers |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
72 |
" private String s1 = \"str 1\";", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
73 |
" public String s2 = \"str 2\";", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
74 |
" protected final String s3 = \"str 3\";", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
75 |
" static String s4 = \"str 4\";", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
76 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
77 |
// Methods with various combinations of types and modifiers |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
78 |
" protected void m1() {}", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
79 |
" public static Map<Integer, List<String>> m2() {", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
80 |
" return null;", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
81 |
" }", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
82 |
" final void m3(Set<Map<Integer, Map<String, String>>> s) {}", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
83 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
84 |
// Some inner classes |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
85 |
" static class DummyInner1 implements Runnable {", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
86 |
" protected int field;", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
87 |
" public void run() {}", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
88 |
" }", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
89 |
" final class DummyInner2 { }", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
90 |
"}"); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
91 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
92 |
// Create class file to extract API from |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
36778
diff
changeset
|
93 |
new JavacTask(new ToolBox()).sources(testSrc).run(); |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
94 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
95 |
// Extract PubApi |
32799 | 96 |
Options options = Options.parseArgs("-d", "bin", "--state-dir=bin", "-cp", "."); |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
97 |
PubApiExtractor pubApiExtr = new PubApiExtractor(options); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
98 |
PubApi actualApi = pubApiExtr.getPubApi("TestClass"); |
33553
9a742b6b95d3
8137075: Sjavac tests are leaking file managers
alundblad
parents:
32799
diff
changeset
|
99 |
pubApiExtr.close(); |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
100 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
101 |
// Validate result |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
102 |
PubApi expectedApi = getExpectedPubApi(); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
103 |
if (!expectedApi.equals(actualApi)) { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
104 |
List<String> diffs = expectedApi.diff(actualApi); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
105 |
System.out.println(diffs.size() + " differences found."); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
106 |
for (String diff : diffs) { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
107 |
System.out.println(diff); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
108 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
109 |
throw new AssertionError("Actual API differs from expected API."); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
110 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
111 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
112 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
113 |
private static PubApi getExpectedPubApi() { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
114 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
115 |
ReferenceTypeDesc string = new ReferenceTypeDesc("java.lang.String"); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
116 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
117 |
// Fields |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
118 |
// (s1 is private and therefore not included) |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
119 |
PubVar s2 = new PubVar(setOf(PUBLIC), string, "s2", null); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
120 |
PubVar s4 = new PubVar(setOf(STATIC), string, "s4", null); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
121 |
PubVar s3 = new PubVar(setOf(PROTECTED, FINAL), string, "s3", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
122 |
"\"\\u0073\\u0074\\u0072\\u0020\\u0033\""); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
123 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
124 |
// Methods |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
125 |
PubMethod init = new PubMethod(setOf(PUBLIC), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
126 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
127 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
128 |
"<init>", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
129 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
130 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
131 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
132 |
PubMethod clinit = new PubMethod(setOf(STATIC), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
133 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
134 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
135 |
"<clinit>", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
136 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
137 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
138 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
139 |
PubMethod m1 = new PubMethod(setOf(PROTECTED), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
140 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
141 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
142 |
"m1", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
143 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
144 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
145 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
146 |
PubMethod m2 = new PubMethod(setOf(PUBLIC, STATIC), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
147 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
148 |
new ReferenceTypeDesc("java.util.Map"), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
149 |
"m2", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
150 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
151 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
152 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
153 |
PubMethod m3 = new PubMethod(setOf(FINAL), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
154 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
155 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
156 |
"m3", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
157 |
asList(new ReferenceTypeDesc("java.util.Set")), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
158 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
159 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
160 |
// Complete class |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
161 |
PubType testClass = new PubType(setOf(PUBLIC, FINAL), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
162 |
"TestClass", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
163 |
new PubApi(asList(getDummyInner1(), getDummyInner2()), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
164 |
asList(s2, s3, s4), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
165 |
asList(init, clinit, m1, m2, m3))); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
166 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
167 |
// Wrap in "package level" PubApi |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
168 |
return new PubApi(asList(testClass), emptyList(), emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
169 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
170 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
171 |
private static PubType getDummyInner1() { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
172 |
PubMethod init = new PubMethod(setOf(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
173 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
174 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
175 |
"<init>", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
176 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
177 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
178 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
179 |
PubMethod run = new PubMethod(setOf(PUBLIC), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
180 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
181 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
182 |
"run", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
183 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
184 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
185 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
186 |
PubVar field = new PubVar(setOf(PROTECTED), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
187 |
new PrimitiveTypeDesc(TypeKind.INT), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
188 |
"field", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
189 |
null); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
190 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
191 |
return new PubType(setOf(STATIC), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
192 |
"TestClass$DummyInner1", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
193 |
new PubApi(emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
194 |
asList(field), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
195 |
asList(init, run))); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
196 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
197 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
198 |
private static PubType getDummyInner2() { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
199 |
PubMethod init = new PubMethod(setOf(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
200 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
201 |
new PrimitiveTypeDesc(TypeKind.VOID), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
202 |
"<init>", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
203 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
204 |
emptyList()); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
205 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
206 |
return new PubType(setOf(FINAL), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
207 |
"TestClass$DummyInner2", |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
208 |
new PubApi(emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
209 |
emptyList(), |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
210 |
asList(init))); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
211 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
212 |
|
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
213 |
@SafeVarargs |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
214 |
private static <T> Set<T> setOf(T... elements) { |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
215 |
return new HashSet<>(asList(elements)); |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
216 |
} |
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff
changeset
|
217 |
} |