author | iignatyev |
Mon, 18 Feb 2019 09:31:07 -0800 | |
changeset 53791 | bec6c8739833 |
parent 51016 | a926b7737d3b |
permissions | -rw-r--r-- |
23192 | 1 |
/* |
51016 | 2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
23192 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
51016 | 7 |
* published by the Free Software Foundation. |
23192 | 8 |
* |
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test TestStableBoolean |
|
26 |
* @summary tests on stable fields and arrays |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
27 |
* @library /test/lib / |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36616
diff
changeset
|
28 |
* @modules java.base/jdk.internal.misc |
36508 | 29 |
* @modules java.base/jdk.internal.vm.annotation |
30 |
* @build sun.hotspot.WhiteBox |
|
23192 | 31 |
* |
38188
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
32 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
33 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
34 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
35 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
36 |
* compiler.stable.TestStableBoolean |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
37 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
38 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
39 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
40 |
* -XX:-FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
41 |
* compiler.stable.TestStableBoolean |
23192 | 42 |
* |
38188
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
43 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
44 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
45 |
* -XX:+TieredCompilation -XX:TieredStopAtLevel=1 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
46 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
47 |
* compiler.stable.TestStableBoolean |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
48 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
49 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
50 |
* -XX:+TieredCompilation -XX:TieredStopAtLevel=1 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
51 |
* -XX:-FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
52 |
* compiler.stable.TestStableBoolean |
23192 | 53 |
*/ |
36508 | 54 |
|
55 |
package compiler.stable; |
|
23192 | 56 |
|
35099
982950884444
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
33730
diff
changeset
|
57 |
import jdk.internal.vm.annotation.Stable; |
40059 | 58 |
|
23192 | 59 |
import java.lang.reflect.InvocationTargetException; |
60 |
||
61 |
public class TestStableBoolean { |
|
36604 | 62 |
static final boolean isStableEnabled = StableConfiguration.isStableEnabled; |
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
63 |
|
23192 | 64 |
public static void main(String[] args) throws Exception { |
65 |
run(DefaultValue.class); |
|
66 |
run(BooleanStable.class); |
|
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
67 |
run(DefaultStaticValue.class); |
23192 | 68 |
run(StaticBooleanStable.class); |
69 |
run(VolatileBooleanStable.class); |
|
70 |
||
71 |
// @Stable arrays: Dim 1-4 |
|
72 |
run(BooleanArrayDim1.class); |
|
73 |
run(BooleanArrayDim2.class); |
|
74 |
run(BooleanArrayDim3.class); |
|
75 |
run(BooleanArrayDim4.class); |
|
76 |
||
77 |
// @Stable Object field: dynamic arrays |
|
78 |
run(ObjectArrayLowerDim0.class); |
|
79 |
run(ObjectArrayLowerDim1.class); |
|
80 |
run(ObjectArrayLowerDim2.class); |
|
81 |
||
82 |
// Nested @Stable fields |
|
83 |
run(NestedStableField.class); |
|
84 |
run(NestedStableField1.class); |
|
85 |
run(NestedStableField2.class); |
|
86 |
run(NestedStableField3.class); |
|
87 |
||
88 |
if (failed) { |
|
89 |
throw new Error("TEST FAILED"); |
|
90 |
} |
|
91 |
} |
|
92 |
||
93 |
/* ==================================================== */ |
|
94 |
||
95 |
static class DefaultValue { |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
96 |
public @Stable boolean v; |
23192 | 97 |
|
98 |
public static final DefaultValue c = new DefaultValue(); |
|
99 |
public static boolean get() { return c.v; } |
|
100 |
public static void test() throws Exception { |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
101 |
boolean val1 = get(); |
23192 | 102 |
c.v = true; boolean val2 = get(); |
103 |
assertEquals(val1, false); |
|
104 |
assertEquals(val2, true); |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
/* ==================================================== */ |
|
109 |
||
110 |
static class BooleanStable { |
|
111 |
public @Stable boolean v; |
|
112 |
||
113 |
public static final BooleanStable c = new BooleanStable(); |
|
114 |
public static boolean get() { return c.v; } |
|
115 |
public static void test() throws Exception { |
|
116 |
c.v = true; boolean val1 = get(); |
|
117 |
c.v = false; boolean val2 = get(); |
|
118 |
assertEquals(val1, true); |
|
119 |
assertEquals(val2, (isStableEnabled ? true : false)); |
|
120 |
} |
|
121 |
} |
|
122 |
||
123 |
/* ==================================================== */ |
|
124 |
||
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
125 |
static class DefaultStaticValue { |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
126 |
public static @Stable boolean v; |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
127 |
|
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
128 |
public static final DefaultStaticValue c = new DefaultStaticValue(); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
129 |
public static boolean get() { return c.v; } |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
130 |
public static void test() throws Exception { |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
131 |
boolean val1 = get(); |
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
132 |
c.v = true; boolean val2 = get(); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
133 |
assertEquals(val1, false); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
134 |
assertEquals(val2, true); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
135 |
} |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
136 |
} |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
137 |
|
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
138 |
/* ==================================================== */ |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
139 |
|
23192 | 140 |
static class StaticBooleanStable { |
141 |
public static @Stable boolean v; |
|
142 |
||
143 |
public static final StaticBooleanStable c = new StaticBooleanStable(); |
|
144 |
public static boolean get() { return c.v; } |
|
145 |
public static void test() throws Exception { |
|
146 |
c.v = true; boolean val1 = get(); |
|
147 |
c.v = false; boolean val2 = get(); |
|
148 |
assertEquals(val1, true); |
|
149 |
assertEquals(val2, (isStableEnabled ? true : false)); |
|
150 |
} |
|
151 |
} |
|
152 |
||
153 |
/* ==================================================== */ |
|
154 |
||
155 |
static class VolatileBooleanStable { |
|
156 |
public @Stable volatile boolean v; |
|
157 |
||
158 |
public static final VolatileBooleanStable c = new VolatileBooleanStable(); |
|
159 |
public static boolean get() { return c.v; } |
|
160 |
public static void test() throws Exception { |
|
161 |
c.v = true; boolean val1 = get(); |
|
162 |
c.v = false; boolean val2 = get(); |
|
163 |
assertEquals(val1, true); |
|
164 |
assertEquals(val2, (isStableEnabled ? true : false)); |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
/* ==================================================== */ |
|
169 |
// @Stable array == field && all components are stable |
|
170 |
||
171 |
static class BooleanArrayDim1 { |
|
172 |
public @Stable boolean[] v; |
|
173 |
||
174 |
public static final BooleanArrayDim1 c = new BooleanArrayDim1(); |
|
175 |
public static boolean get() { return c.v[0]; } |
|
176 |
public static boolean get1() { return c.v[10]; } |
|
177 |
public static boolean[] get2() { return c.v; } |
|
178 |
public static void test() throws Exception { |
|
179 |
{ |
|
180 |
c.v = new boolean[1]; c.v[0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
181 |
c.v[0] = false; boolean val2 = get(); |
23192 | 182 |
assertEquals(val1, true); |
36604 | 183 |
assertEquals(val2, (isStableEnabled ? true : false)); |
23192 | 184 |
} |
185 |
||
186 |
{ |
|
187 |
c.v = new boolean[20]; c.v[10] = true; boolean val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
188 |
c.v[10] = false; boolean val2 = get1(); |
23192 | 189 |
assertEquals(val1, true); |
36604 | 190 |
assertEquals(val2, (isStableEnabled ? true : false)); |
23192 | 191 |
} |
192 |
||
193 |
{ |
|
194 |
c.v = new boolean[1]; boolean[] val1 = get2(); |
|
195 |
c.v = new boolean[1]; boolean[] val2 = get2(); |
|
196 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
/* ==================================================== */ |
|
202 |
||
203 |
static class BooleanArrayDim2 { |
|
204 |
public @Stable boolean[][] v; |
|
205 |
||
206 |
public static final BooleanArrayDim2 c = new BooleanArrayDim2(); |
|
207 |
public static boolean get() { return c.v[0][0]; } |
|
208 |
public static boolean[] get1() { return c.v[0]; } |
|
209 |
public static boolean[][] get2() { return c.v; } |
|
210 |
public static void test() throws Exception { |
|
211 |
{ |
|
212 |
c.v = new boolean[1][1]; c.v[0][0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
213 |
c.v[0][0] = false; boolean val2 = get(); |
23192 | 214 |
assertEquals(val1, true); |
36604 | 215 |
assertEquals(val2, (isStableEnabled ? true : false)); |
23192 | 216 |
|
217 |
c.v = new boolean[1][1]; c.v[0][0] = false; boolean val3 = get(); |
|
36604 | 218 |
assertEquals(val3, (isStableEnabled ? true : false)); |
23192 | 219 |
|
220 |
c.v[0] = new boolean[1]; c.v[0][0] = false; boolean val4 = get(); |
|
36604 | 221 |
assertEquals(val4, (isStableEnabled ? true : false)); |
23192 | 222 |
} |
223 |
||
224 |
{ |
|
225 |
c.v = new boolean[1][1]; boolean[] val1 = get1(); |
|
226 |
c.v[0] = new boolean[1]; boolean[] val2 = get1(); |
|
36604 | 227 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 228 |
} |
229 |
||
230 |
{ |
|
231 |
c.v = new boolean[1][1]; boolean[][] val1 = get2(); |
|
232 |
c.v = new boolean[1][1]; boolean[][] val2 = get2(); |
|
233 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
234 |
} |
|
235 |
} |
|
236 |
} |
|
237 |
||
238 |
/* ==================================================== */ |
|
239 |
||
240 |
static class BooleanArrayDim3 { |
|
241 |
public @Stable boolean[][][] v; |
|
242 |
||
243 |
public static final BooleanArrayDim3 c = new BooleanArrayDim3(); |
|
244 |
public static boolean get() { return c.v[0][0][0]; } |
|
245 |
public static boolean[] get1() { return c.v[0][0]; } |
|
246 |
public static boolean[][] get2() { return c.v[0]; } |
|
247 |
public static boolean[][][] get3() { return c.v; } |
|
248 |
public static void test() throws Exception { |
|
249 |
{ |
|
250 |
c.v = new boolean[1][1][1]; c.v[0][0][0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
251 |
c.v[0][0][0] = false; boolean val2 = get(); |
23192 | 252 |
assertEquals(val1, true); |
36604 | 253 |
assertEquals(val2, (isStableEnabled ? true : false)); |
23192 | 254 |
|
255 |
c.v = new boolean[1][1][1]; c.v[0][0][0] = false; boolean val3 = get(); |
|
36604 | 256 |
assertEquals(val3, (isStableEnabled ? true : false)); |
23192 | 257 |
|
258 |
c.v[0] = new boolean[1][1]; c.v[0][0][0] = false; boolean val4 = get(); |
|
36604 | 259 |
assertEquals(val4, (isStableEnabled ? true : false)); |
23192 | 260 |
|
261 |
c.v[0][0] = new boolean[1]; c.v[0][0][0] = false; boolean val5 = get(); |
|
36604 | 262 |
assertEquals(val5, (isStableEnabled ? true : false)); |
23192 | 263 |
} |
264 |
||
265 |
{ |
|
266 |
c.v = new boolean[1][1][1]; boolean[] val1 = get1(); |
|
267 |
c.v[0][0] = new boolean[1]; boolean[] val2 = get1(); |
|
36604 | 268 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 269 |
} |
270 |
||
271 |
{ |
|
272 |
c.v = new boolean[1][1][1]; boolean[][] val1 = get2(); |
|
273 |
c.v[0] = new boolean[1][1]; boolean[][] val2 = get2(); |
|
36604 | 274 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 275 |
} |
276 |
||
277 |
{ |
|
278 |
c.v = new boolean[1][1][1]; boolean[][][] val1 = get3(); |
|
279 |
c.v = new boolean[1][1][1]; boolean[][][] val2 = get3(); |
|
280 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
281 |
} |
|
282 |
} |
|
283 |
} |
|
284 |
||
285 |
/* ==================================================== */ |
|
286 |
||
287 |
static class BooleanArrayDim4 { |
|
288 |
public @Stable boolean[][][][] v; |
|
289 |
||
290 |
public static final BooleanArrayDim4 c = new BooleanArrayDim4(); |
|
291 |
public static boolean get() { return c.v[0][0][0][0]; } |
|
292 |
public static boolean[] get1() { return c.v[0][0][0]; } |
|
293 |
public static boolean[][] get2() { return c.v[0][0]; } |
|
294 |
public static boolean[][][] get3() { return c.v[0]; } |
|
295 |
public static boolean[][][][] get4() { return c.v; } |
|
296 |
public static void test() throws Exception { |
|
297 |
{ |
|
298 |
c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
299 |
c.v[0][0][0][0] = false; boolean val2 = get(); |
23192 | 300 |
assertEquals(val1, true); |
36604 | 301 |
assertEquals(val2, (isStableEnabled ? true : false)); |
23192 | 302 |
|
303 |
c.v = new boolean[1][1][1][1]; c.v[0][0][0][0] = false; boolean val3 = get(); |
|
36604 | 304 |
assertEquals(val3, (isStableEnabled ? true : false)); |
23192 | 305 |
|
306 |
c.v[0] = new boolean[1][1][1]; c.v[0][0][0][0] = false; boolean val4 = get(); |
|
36604 | 307 |
assertEquals(val4, (isStableEnabled ? true : false)); |
23192 | 308 |
|
309 |
c.v[0][0] = new boolean[1][1]; c.v[0][0][0][0] = false; boolean val5 = get(); |
|
36604 | 310 |
assertEquals(val5, (isStableEnabled ? true : false)); |
23192 | 311 |
|
312 |
c.v[0][0][0] = new boolean[1]; c.v[0][0][0][0] = false; boolean val6 = get(); |
|
36604 | 313 |
assertEquals(val6, (isStableEnabled ? true : false)); |
23192 | 314 |
} |
315 |
||
316 |
{ |
|
317 |
c.v = new boolean[1][1][1][1]; boolean[] val1 = get1(); |
|
318 |
c.v[0][0][0] = new boolean[1]; boolean[] val2 = get1(); |
|
36604 | 319 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 320 |
} |
321 |
||
322 |
{ |
|
323 |
c.v = new boolean[1][1][1][1]; boolean[][] val1 = get2(); |
|
324 |
c.v[0][0] = new boolean[1][1]; boolean[][] val2 = get2(); |
|
36604 | 325 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 326 |
} |
327 |
||
328 |
{ |
|
329 |
c.v = new boolean[1][1][1][1]; boolean[][][] val1 = get3(); |
|
330 |
c.v[0] = new boolean[1][1][1]; boolean[][][] val2 = get3(); |
|
36604 | 331 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 332 |
} |
333 |
||
334 |
{ |
|
335 |
c.v = new boolean[1][1][1][1]; boolean[][][][] val1 = get4(); |
|
336 |
c.v = new boolean[1][1][1][1]; boolean[][][][] val2 = get4(); |
|
337 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
338 |
} |
|
339 |
||
340 |
} |
|
341 |
} |
|
342 |
||
343 |
/* ==================================================== */ |
|
344 |
// Dynamic Dim is higher than static |
|
345 |
||
346 |
static class ObjectArrayLowerDim0 { |
|
347 |
public @Stable Object v; |
|
348 |
||
349 |
public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0(); |
|
350 |
public static boolean get() { return ((boolean[])c.v)[0]; } |
|
351 |
public static boolean[] get1() { return (boolean[])c.v; } |
|
352 |
public static boolean[] get2() { return (boolean[])c.v; } |
|
353 |
||
354 |
public static void test() throws Exception { |
|
355 |
{ |
|
356 |
c.v = new boolean[1]; ((boolean[])c.v)[0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
357 |
((boolean[])c.v)[0] = false; boolean val2 = get(); |
23192 | 358 |
|
359 |
assertEquals(val1, true); |
|
360 |
assertEquals(val2, false); |
|
361 |
} |
|
362 |
||
363 |
{ |
|
364 |
c.v = new boolean[1]; boolean[] val1 = get1(); |
|
365 |
c.v = new boolean[1]; boolean[] val2 = get1(); |
|
366 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
/* ==================================================== */ |
|
372 |
||
373 |
static class ObjectArrayLowerDim1 { |
|
374 |
public @Stable Object[] v; |
|
375 |
||
376 |
public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1(); |
|
377 |
public static boolean get() { return ((boolean[][])c.v)[0][0]; } |
|
378 |
public static boolean[] get1() { return (boolean[])(c.v[0]); } |
|
379 |
public static Object[] get2() { return c.v; } |
|
380 |
||
381 |
public static void test() throws Exception { |
|
382 |
{ |
|
383 |
c.v = new boolean[1][1]; ((boolean[][])c.v)[0][0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
384 |
((boolean[][])c.v)[0][0] = false; boolean val2 = get(); |
23192 | 385 |
|
386 |
assertEquals(val1, true); |
|
387 |
assertEquals(val2, false); |
|
388 |
} |
|
389 |
||
390 |
{ |
|
391 |
c.v = new boolean[1][1]; c.v[0] = new boolean[0]; boolean[] val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
392 |
c.v[0] = new boolean[0]; boolean[] val2 = get1(); |
23192 | 393 |
|
36604 | 394 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 395 |
} |
396 |
||
397 |
{ |
|
398 |
c.v = new boolean[0][0]; Object[] val1 = get2(); |
|
399 |
c.v = new boolean[0][0]; Object[] val2 = get2(); |
|
400 |
||
401 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
402 |
} |
|
403 |
} |
|
404 |
} |
|
405 |
||
406 |
/* ==================================================== */ |
|
407 |
||
408 |
static class ObjectArrayLowerDim2 { |
|
409 |
public @Stable Object[][] v; |
|
410 |
||
411 |
public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2(); |
|
412 |
public static boolean get() { return ((boolean[][][])c.v)[0][0][0]; } |
|
413 |
public static boolean[] get1() { return (boolean[])(c.v[0][0]); } |
|
414 |
public static boolean[][] get2() { return (boolean[][])(c.v[0]); } |
|
415 |
public static Object[][] get3() { return c.v; } |
|
416 |
||
417 |
public static void test() throws Exception { |
|
418 |
{ |
|
419 |
c.v = new boolean[1][1][1]; ((boolean[][][])c.v)[0][0][0] = true; boolean val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
420 |
((boolean[][][])c.v)[0][0][0] = false; boolean val2 = get(); |
23192 | 421 |
|
422 |
assertEquals(val1, true); |
|
423 |
assertEquals(val2, false); |
|
424 |
} |
|
425 |
||
426 |
{ |
|
427 |
c.v = new boolean[1][1][1]; c.v[0][0] = new boolean[0]; boolean[] val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
428 |
c.v[0][0] = new boolean[0]; boolean[] val2 = get1(); |
23192 | 429 |
|
36604 | 430 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 431 |
} |
432 |
||
433 |
{ |
|
434 |
c.v = new boolean[1][1][1]; c.v[0] = new boolean[0][0]; boolean[][] val1 = get2(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
435 |
c.v[0] = new boolean[0][0]; boolean[][] val2 = get2(); |
23192 | 436 |
|
36604 | 437 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 438 |
} |
439 |
||
440 |
{ |
|
441 |
c.v = new boolean[0][0][0]; Object[][] val1 = get3(); |
|
442 |
c.v = new boolean[0][0][0]; Object[][] val2 = get3(); |
|
443 |
||
444 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
||
449 |
/* ==================================================== */ |
|
450 |
||
451 |
static class NestedStableField { |
|
452 |
static class A { |
|
453 |
public @Stable boolean a; |
|
454 |
||
455 |
} |
|
456 |
public @Stable A v; |
|
457 |
||
458 |
public static final NestedStableField c = new NestedStableField(); |
|
459 |
public static A get() { return c.v; } |
|
460 |
public static boolean get1() { return get().a; } |
|
461 |
||
462 |
public static void test() throws Exception { |
|
463 |
{ |
|
464 |
c.v = new A(); c.v.a = true; A val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
465 |
c.v.a = false; A val2 = get(); |
23192 | 466 |
|
467 |
assertEquals(val1.a, false); |
|
468 |
assertEquals(val2.a, false); |
|
469 |
} |
|
470 |
||
471 |
{ |
|
472 |
c.v = new A(); c.v.a = true; boolean val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
473 |
c.v.a = false; boolean val2 = get1(); |
23192 | 474 |
c.v = new A(); c.v.a = false; boolean val3 = get1(); |
475 |
||
476 |
assertEquals(val1, true); |
|
477 |
assertEquals(val2, (isStableEnabled ? true : false)); |
|
478 |
assertEquals(val3, (isStableEnabled ? true : false)); |
|
479 |
} |
|
480 |
} |
|
481 |
} |
|
482 |
||
483 |
/* ==================================================== */ |
|
484 |
||
485 |
static class NestedStableField1 { |
|
486 |
static class A { |
|
487 |
public @Stable boolean a; |
|
488 |
public @Stable A next; |
|
489 |
} |
|
490 |
public @Stable A v; |
|
491 |
||
492 |
public static final NestedStableField1 c = new NestedStableField1(); |
|
493 |
public static A get() { return c.v.next.next.next.next.next.next.next; } |
|
494 |
public static boolean get1() { return get().a; } |
|
495 |
||
496 |
public static void test() throws Exception { |
|
497 |
{ |
|
498 |
c.v = new A(); c.v.next = new A(); c.v.next.next = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
499 |
c.v.a = true; c.v.next.a = true; A val1 = get(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
500 |
c.v.a = false; c.v.next.a = false; A val2 = get(); |
23192 | 501 |
|
502 |
assertEquals(val1.a, false); |
|
503 |
assertEquals(val2.a, false); |
|
504 |
} |
|
505 |
||
506 |
{ |
|
507 |
c.v = new A(); c.v.next = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
508 |
c.v.a = true; boolean val1 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
509 |
c.v.a = false; boolean val2 = get1(); |
23192 | 510 |
c.v = new A(); c.v.next = c.v; |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
511 |
c.v.a = false; boolean val3 = get1(); |
23192 | 512 |
|
513 |
assertEquals(val1, true); |
|
514 |
assertEquals(val2, (isStableEnabled ? true : false)); |
|
515 |
assertEquals(val3, (isStableEnabled ? true : false)); |
|
516 |
} |
|
517 |
} |
|
518 |
} |
|
519 |
/* ==================================================== */ |
|
520 |
||
521 |
static class NestedStableField2 { |
|
522 |
static class A { |
|
523 |
public @Stable boolean a; |
|
524 |
public @Stable A left; |
|
525 |
public A right; |
|
526 |
} |
|
527 |
||
528 |
public @Stable A v; |
|
529 |
||
530 |
public static final NestedStableField2 c = new NestedStableField2(); |
|
531 |
public static boolean get() { return c.v.left.left.left.a; } |
|
532 |
public static boolean get1() { return c.v.left.left.right.left.a; } |
|
533 |
||
534 |
public static void test() throws Exception { |
|
535 |
{ |
|
536 |
c.v = new A(); c.v.left = c.v.right = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
537 |
c.v.a = true; boolean val1 = get(); boolean val2 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
538 |
c.v.a = false; boolean val3 = get(); boolean val4 = get1(); |
23192 | 539 |
|
540 |
assertEquals(val1, true); |
|
541 |
assertEquals(val3, (isStableEnabled ? true : false)); |
|
542 |
||
543 |
assertEquals(val2, true); |
|
544 |
assertEquals(val4, false); |
|
545 |
} |
|
546 |
} |
|
547 |
} |
|
548 |
||
549 |
/* ==================================================== */ |
|
550 |
||
551 |
static class NestedStableField3 { |
|
552 |
static class A { |
|
553 |
public @Stable boolean a; |
|
554 |
public @Stable A[] left; |
|
555 |
public A[] right; |
|
556 |
} |
|
557 |
||
558 |
public @Stable A[] v; |
|
559 |
||
560 |
public static final NestedStableField3 c = new NestedStableField3(); |
|
561 |
public static boolean get() { return c.v[0].left[1].left[0].left[1].a; } |
|
562 |
public static boolean get1() { return c.v[1].left[0].left[1].right[0].left[1].a; } |
|
563 |
||
564 |
public static void test() throws Exception { |
|
565 |
{ |
|
566 |
A elem = new A(); |
|
567 |
c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
568 |
elem.a = true; boolean val1 = get(); boolean val2 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
569 |
elem.a = false; boolean val3 = get(); boolean val4 = get1(); |
23192 | 570 |
|
571 |
assertEquals(val1, true); |
|
36604 | 572 |
assertEquals(val3, (isStableEnabled ? true : false)); |
23192 | 573 |
|
574 |
assertEquals(val2, true); |
|
575 |
assertEquals(val4, false); |
|
576 |
} |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
/* ==================================================== */ |
|
581 |
// Auxiliary methods |
|
582 |
static void assertEquals(boolean i, boolean j) { if (i != j) throw new AssertionError(i + " != " + j); } |
|
583 |
static void assertTrue(boolean b) { if (!b) throw new AssertionError(); } |
|
584 |
||
585 |
static boolean failed = false; |
|
586 |
||
587 |
public static void run(Class<?> test) { |
|
588 |
Throwable ex = null; |
|
589 |
System.out.print(test.getName()+": "); |
|
590 |
try { |
|
591 |
test.getMethod("test").invoke(null); |
|
592 |
} catch (InvocationTargetException e) { |
|
593 |
ex = e.getCause(); |
|
594 |
} catch (Throwable e) { |
|
595 |
ex = e; |
|
596 |
} finally { |
|
597 |
if (ex == null) { |
|
598 |
System.out.println("PASSED"); |
|
599 |
} else { |
|
600 |
failed = true; |
|
601 |
System.out.println("FAILED"); |
|
602 |
ex.printStackTrace(System.out); |
|
603 |
} |
|
604 |
} |
|
605 |
} |
|
606 |
} |