59 import jdk.internal.vm.annotation.Stable; |
59 import jdk.internal.vm.annotation.Stable; |
60 import java.lang.reflect.InvocationTargetException; |
60 import java.lang.reflect.InvocationTargetException; |
61 |
61 |
62 public class TestStableInt { |
62 public class TestStableInt { |
63 static final boolean isStableEnabled = StableConfiguration.isStableEnabled; |
63 static final boolean isStableEnabled = StableConfiguration.isStableEnabled; |
64 static final boolean isServerWithStable = StableConfiguration.isServerWithStable; |
|
65 |
64 |
66 public static void main(String[] args) throws Exception { |
65 public static void main(String[] args) throws Exception { |
67 run(DefaultValue.class); |
66 run(DefaultValue.class); |
68 run(IntStable.class); |
67 run(IntStable.class); |
69 run(DefaultStaticValue.class); |
68 run(DefaultStaticValue.class); |
180 public static void test() throws Exception { |
179 public static void test() throws Exception { |
181 { |
180 { |
182 c.v = new int[1]; c.v[0] = 1; int val1 = get(); |
181 c.v = new int[1]; c.v[0] = 1; int val1 = get(); |
183 c.v[0] = 2; int val2 = get(); |
182 c.v[0] = 2; int val2 = get(); |
184 assertEquals(val1, 1); |
183 assertEquals(val1, 1); |
185 assertEquals(val2, (isServerWithStable ? 1 : 2)); |
184 assertEquals(val2, (isStableEnabled ? 1 : 2)); |
186 |
185 |
187 c.v = new int[1]; c.v[0] = 3; int val3 = get(); |
186 c.v = new int[1]; c.v[0] = 3; int val3 = get(); |
188 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
187 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
189 : 3)); |
188 : 3)); |
190 } |
189 } |
191 |
190 |
192 { |
191 { |
193 c.v = new int[20]; c.v[10] = 1; int val1 = get1(); |
192 c.v = new int[20]; c.v[10] = 1; int val1 = get1(); |
194 c.v[10] = 2; int val2 = get1(); |
193 c.v[10] = 2; int val2 = get1(); |
195 assertEquals(val1, 1); |
194 assertEquals(val1, 1); |
196 assertEquals(val2, (isServerWithStable ? 1 : 2)); |
195 assertEquals(val2, (isStableEnabled ? 1 : 2)); |
197 |
196 |
198 c.v = new int[20]; c.v[10] = 3; int val3 = get1(); |
197 c.v = new int[20]; c.v[10] = 3; int val3 = get1(); |
199 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
198 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
200 : 3)); |
199 : 3)); |
201 } |
200 } |
202 |
201 |
203 { |
202 { |
204 c.v = new int[1]; int[] val1 = get2(); |
203 c.v = new int[1]; int[] val1 = get2(); |
220 public static void test() throws Exception { |
219 public static void test() throws Exception { |
221 { |
220 { |
222 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get(); |
221 c.v = new int[1][1]; c.v[0][0] = 1; int val1 = get(); |
223 c.v[0][0] = 2; int val2 = get(); |
222 c.v[0][0] = 2; int val2 = get(); |
224 assertEquals(val1, 1); |
223 assertEquals(val1, 1); |
225 assertEquals(val2, (isServerWithStable ? 1 : 2)); |
224 assertEquals(val2, (isStableEnabled ? 1 : 2)); |
226 |
225 |
227 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get(); |
226 c.v = new int[1][1]; c.v[0][0] = 3; int val3 = get(); |
228 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
227 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
229 : 3)); |
228 : 3)); |
230 |
229 |
231 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get(); |
230 c.v[0] = new int[1]; c.v[0][0] = 4; int val4 = get(); |
232 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
231 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
233 : 4)); |
232 : 4)); |
234 } |
233 } |
235 |
234 |
236 { |
235 { |
237 c.v = new int[1][1]; int[] val1 = get1(); |
236 c.v = new int[1][1]; int[] val1 = get1(); |
238 c.v[0] = new int[1]; int[] val2 = get1(); |
237 c.v[0] = new int[1]; int[] val2 = get1(); |
239 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
238 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
240 } |
239 } |
241 |
240 |
242 { |
241 { |
243 c.v = new int[1][1]; int[][] val1 = get2(); |
242 c.v = new int[1][1]; int[][] val1 = get2(); |
244 c.v = new int[1][1]; int[][] val2 = get2(); |
243 c.v = new int[1][1]; int[][] val2 = get2(); |
260 public static void test() throws Exception { |
259 public static void test() throws Exception { |
261 { |
260 { |
262 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get(); |
261 c.v = new int[1][1][1]; c.v[0][0][0] = 1; int val1 = get(); |
263 c.v[0][0][0] = 2; int val2 = get(); |
262 c.v[0][0][0] = 2; int val2 = get(); |
264 assertEquals(val1, 1); |
263 assertEquals(val1, 1); |
265 assertEquals(val2, (isServerWithStable ? 1 : 2)); |
264 assertEquals(val2, (isStableEnabled ? 1 : 2)); |
266 |
265 |
267 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get(); |
266 c.v = new int[1][1][1]; c.v[0][0][0] = 3; int val3 = get(); |
268 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
267 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
269 : 3)); |
268 : 3)); |
270 |
269 |
271 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get(); |
270 c.v[0] = new int[1][1]; c.v[0][0][0] = 4; int val4 = get(); |
272 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
271 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
273 : 4)); |
272 : 4)); |
274 |
273 |
275 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get(); |
274 c.v[0][0] = new int[1]; c.v[0][0][0] = 5; int val5 = get(); |
276 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
275 assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
277 : 5)); |
276 : 5)); |
278 } |
277 } |
279 |
278 |
280 { |
279 { |
281 c.v = new int[1][1][1]; int[] val1 = get1(); |
280 c.v = new int[1][1][1]; int[] val1 = get1(); |
282 c.v[0][0] = new int[1]; int[] val2 = get1(); |
281 c.v[0][0] = new int[1]; int[] val2 = get1(); |
283 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
282 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
284 } |
283 } |
285 |
284 |
286 { |
285 { |
287 c.v = new int[1][1][1]; int[][] val1 = get2(); |
286 c.v = new int[1][1][1]; int[][] val1 = get2(); |
288 c.v[0] = new int[1][1]; int[][] val2 = get2(); |
287 c.v[0] = new int[1][1]; int[][] val2 = get2(); |
289 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
288 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
290 } |
289 } |
291 |
290 |
292 { |
291 { |
293 c.v = new int[1][1][1]; int[][][] val1 = get3(); |
292 c.v = new int[1][1][1]; int[][][] val1 = get3(); |
294 c.v = new int[1][1][1]; int[][][] val2 = get3(); |
293 c.v = new int[1][1][1]; int[][][] val2 = get3(); |
311 public static void test() throws Exception { |
310 public static void test() throws Exception { |
312 { |
311 { |
313 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get(); |
312 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 1; int val1 = get(); |
314 c.v[0][0][0][0] = 2; int val2 = get(); |
313 c.v[0][0][0][0] = 2; int val2 = get(); |
315 assertEquals(val1, 1); |
314 assertEquals(val1, 1); |
316 assertEquals(val2, (isServerWithStable ? 1 : 2)); |
315 assertEquals(val2, (isStableEnabled ? 1 : 2)); |
317 |
316 |
318 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get(); |
317 c.v = new int[1][1][1][1]; c.v[0][0][0][0] = 3; int val3 = get(); |
319 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
318 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
320 : 3)); |
319 : 3)); |
321 |
320 |
322 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get(); |
321 c.v[0] = new int[1][1][1]; c.v[0][0][0][0] = 4; int val4 = get(); |
323 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
322 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
324 : 4)); |
323 : 4)); |
325 |
324 |
326 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get(); |
325 c.v[0][0] = new int[1][1]; c.v[0][0][0][0] = 5; int val5 = get(); |
327 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
326 assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
328 : 5)); |
327 : 5)); |
329 |
328 |
330 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get(); |
329 c.v[0][0][0] = new int[1]; c.v[0][0][0][0] = 6; int val6 = get(); |
331 assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1 : 2) |
330 assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1 : 2) |
332 : 6)); |
331 : 6)); |
333 } |
332 } |
334 |
333 |
335 { |
334 { |
336 c.v = new int[1][1][1][1]; int[] val1 = get1(); |
335 c.v = new int[1][1][1][1]; int[] val1 = get1(); |
337 c.v[0][0][0] = new int[1]; int[] val2 = get1(); |
336 c.v[0][0][0] = new int[1]; int[] val2 = get1(); |
338 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
337 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
339 } |
338 } |
340 |
339 |
341 { |
340 { |
342 c.v = new int[1][1][1][1]; int[][] val1 = get2(); |
341 c.v = new int[1][1][1][1]; int[][] val1 = get2(); |
343 c.v[0][0] = new int[1][1]; int[][] val2 = get2(); |
342 c.v[0][0] = new int[1][1]; int[][] val2 = get2(); |
344 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
343 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
345 } |
344 } |
346 |
345 |
347 { |
346 { |
348 c.v = new int[1][1][1][1]; int[][][] val1 = get3(); |
347 c.v = new int[1][1][1][1]; int[][][] val1 = get3(); |
349 c.v[0] = new int[1][1][1]; int[][][] val2 = get3(); |
348 c.v[0] = new int[1][1][1]; int[][][] val2 = get3(); |
350 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
349 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
351 } |
350 } |
352 |
351 |
353 { |
352 { |
354 c.v = new int[1][1][1][1]; int[][][][] val1 = get4(); |
353 c.v = new int[1][1][1][1]; int[][][][] val1 = get4(); |
355 c.v = new int[1][1][1][1]; int[][][][] val2 = get4(); |
354 c.v = new int[1][1][1][1]; int[][][][] val2 = get4(); |
441 |
440 |
442 { |
441 { |
443 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1(); |
442 c.v = new int[1][1][1]; c.v[0][0] = new int[0]; int[] val1 = get1(); |
444 c.v[0][0] = new int[0]; int[] val2 = get1(); |
443 c.v[0][0] = new int[0]; int[] val2 = get1(); |
445 |
444 |
446 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
445 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
447 } |
446 } |
448 |
447 |
449 { |
448 { |
450 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2(); |
449 c.v = new int[1][1][1]; c.v[0] = new int[0][0]; int[][] val1 = get2(); |
451 c.v[0] = new int[0][0]; int[][] val2 = get2(); |
450 c.v[0] = new int[0][0]; int[][] val2 = get2(); |
452 |
451 |
453 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
452 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
454 } |
453 } |
455 |
454 |
456 { |
455 { |
457 c.v = new int[0][0][0]; Object[][] val1 = get3(); |
456 c.v = new int[0][0][0]; Object[][] val1 = get3(); |
458 c.v = new int[0][0][0]; Object[][] val2 = get3(); |
457 c.v = new int[0][0][0]; Object[][] val2 = get3(); |
583 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; |
582 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; |
584 elem.a = 1; int val1 = get(); int val2 = get1(); |
583 elem.a = 1; int val1 = get(); int val2 = get1(); |
585 elem.a = 2; int val3 = get(); int val4 = get1(); |
584 elem.a = 2; int val3 = get(); int val4 = get1(); |
586 |
585 |
587 assertEquals(val1, 1); |
586 assertEquals(val1, 1); |
588 assertEquals(val3, (isServerWithStable ? 1 : 2)); |
587 assertEquals(val3, (isStableEnabled ? 1 : 2)); |
589 |
588 |
590 assertEquals(val2, 1); |
589 assertEquals(val2, 1); |
591 assertEquals(val4, 2); |
590 assertEquals(val4, 2); |
592 } |
591 } |
593 } |
592 } |