author | jlahoda |
Thu, 09 Oct 2014 10:08:52 +0200 | |
changeset 26993 | 513b2cae81c3 |
parent 26103 | 3f96599b20da |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
26101
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
1 |
/* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
4 |
* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
8 |
* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
13 |
* accompanied this code). |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
14 |
* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
18 |
* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
21 |
* questions. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
22 |
*/ |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
23 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
24 |
/* |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
25 |
* @test |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
26 |
* @bug 8042251 |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
27 |
* @summary Testing InnerClasses_attribute of inner classes in local class. |
26103 | 28 |
* @library /tools/lib /tools/javac/lib ../lib |
26101
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
29 |
* @build InnerClassesTestBase TestResult TestBase InMemoryFileManager ToolBox |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
30 |
* @run main InnerClassesInLocalClassTest |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
31 |
*/ |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
32 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
33 |
import java.util.*; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
34 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
35 |
public class InnerClassesInLocalClassTest extends InnerClassesTestBase { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
36 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
37 |
private final static Modifier[] LOCAL_CLASS_MODIFIERS = |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
38 |
new Modifier[]{Modifier.EMPTY, Modifier.ABSTRACT, Modifier.FINAL}; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
39 |
private final static String CLASS_TEMPLATE = |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
40 |
"public %CLASS% OuterClass {\n" + |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
41 |
"%SOURCE%\n" + |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
42 |
"}"; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
43 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
44 |
private final List<Data> innerClassesData; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
45 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
46 |
public InnerClassesInLocalClassTest() { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
47 |
innerClassesData = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
48 |
for (Modifier outerModifier : LOCAL_CLASS_MODIFIERS) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
49 |
StringBuilder sb = new StringBuilder(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
50 |
sb.append(outerModifier.getString()).append(' '); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
51 |
sb.append("class Local {"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
52 |
Map<String, Set<String>> class2Flags = new HashMap<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
53 |
for (int i = 0; i < LOCAL_CLASS_MODIFIERS.length; ++i) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
54 |
Modifier innerModifier = LOCAL_CLASS_MODIFIERS[i]; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
55 |
sb.append(innerModifier.getString()).append(' ') |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
56 |
.append("class").append(' ') |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
57 |
.append('A').append(i).append("{}\n"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
58 |
class2Flags.put("A" + i, getFlags(innerModifier)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
59 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
60 |
sb.append("};"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
61 |
class2Flags.put("1Local", getFlags(outerModifier)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
62 |
innerClassesData.add(new Data(sb.toString(), class2Flags)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
63 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
64 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
65 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
66 |
public static void main(String[] args) throws TestFailedException { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
67 |
InnerClassesTestBase test = new InnerClassesInLocalClassTest(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
68 |
test.test("OuterClass$1Local", "1Local"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
69 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
70 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
71 |
@Override |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
72 |
public void setProperties() { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
73 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
74 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
75 |
@Override |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
76 |
public List<TestCase> generateTestCases() { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
77 |
List<TestCase> testCases = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
78 |
testCases.addAll(localClassInClassMethod()); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
79 |
testCases.addAll(localClassInInterfaceMethod()); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
80 |
return testCases; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
81 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
82 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
83 |
private List<TestCase> localClassInClassMethod() { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
84 |
List<TestCase> list = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
85 |
String template = CLASS_TEMPLATE.replace("%CLASS%", "class"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
86 |
list.addAll(lambda(template)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
87 |
list.addAll(constructor(template)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
88 |
list.addAll(method(template, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
89 |
new Modifier[]{Modifier.EMPTY, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC}, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
90 |
new Modifier[]{Modifier.EMPTY, Modifier.FINAL, Modifier.STATIC})); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
91 |
list.addAll(staticAndInstanceInitializer(template)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
92 |
return list; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
93 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
94 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
95 |
private List<TestCase> localClassInInterfaceMethod() { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
96 |
String template = CLASS_TEMPLATE.replace("%CLASS%", "interface"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
97 |
return method(template, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
98 |
new Modifier[]{Modifier.EMPTY, Modifier.PUBLIC}, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
99 |
new Modifier[]{Modifier.DEFAULT, Modifier.STATIC}); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
100 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
101 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
102 |
private List<TestCase> generate(String template, String prefix, String suffix) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
103 |
List<TestCase> list = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
104 |
for (Data data : innerClassesData) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
105 |
list.add(new TestCase(template.replace("%SOURCE%", |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
106 |
prefix + data.sources + suffix), |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
107 |
data.class2Flags)); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
108 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
109 |
return list; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
110 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
111 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
112 |
private List<TestCase> lambda(String template) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
113 |
return generate(template, "Runnable run = () -> {", "};"); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
114 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
115 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
116 |
private List<TestCase> constructor(String template) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
117 |
List<TestCase> list = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
118 |
for (Modifier modifier : |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
119 |
new Modifier[]{Modifier.EMPTY, Modifier.PRIVATE, Modifier.PROTECTED, Modifier.PUBLIC}) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
120 |
list.addAll(generate(template, modifier.getString() + " OuterClass() {", "}")); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
121 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
122 |
return list; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
123 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
124 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
125 |
private List<TestCase> method(String template, Modifier[] mods, Modifier[] otherMods) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
126 |
List<TestCase> list = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
127 |
for (Modifier modifier : mods) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
128 |
for (Modifier otherMod : otherMods) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
129 |
list.addAll(generate(template, |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
130 |
String.format("%s %s void method() {", |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
131 |
modifier.getString(), |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
132 |
otherMod.getString()), |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
133 |
"}")); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
134 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
135 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
136 |
return list; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
137 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
138 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
139 |
private List<TestCase> staticAndInstanceInitializer(String template) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
140 |
List<TestCase> list = new ArrayList<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
141 |
for (Modifier modifier : new Modifier[]{Modifier.EMPTY, Modifier.STATIC}) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
142 |
list.addAll(generate(template, modifier.getString() + "{", "}")); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
143 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
144 |
return list; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
145 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
146 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
147 |
private Set<String> getFlags(Modifier modifier) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
148 |
HashSet<String> set = new HashSet<>(); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
149 |
if (modifier != Modifier.EMPTY) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
150 |
set.add("ACC_" + modifier.getString().toUpperCase()); |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
151 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
152 |
return set; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
153 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
154 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
155 |
/** |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
156 |
* Class represents part of sources which is inserted in other code. |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
157 |
*/ |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
158 |
private static class Data { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
159 |
public final String sources; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
160 |
public final Map<String, Set<String>> class2Flags; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
161 |
|
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
162 |
public Data(String sources, Map<String, Set<String>> class2Flags) { |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
163 |
this.sources = sources; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
164 |
this.class2Flags = class2Flags; |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
165 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
166 |
} |
d5dd2ecd2353
8042251: Implement classfile tests for InnerClasses attribute.
aeremeev
parents:
diff
changeset
|
167 |
} |