59 import java.lang.reflect.InvocationTargetException; |
59 import java.lang.reflect.InvocationTargetException; |
60 import jdk.internal.vm.annotation.Stable; |
60 import jdk.internal.vm.annotation.Stable; |
61 |
61 |
62 public class TestStableDouble { |
62 public class TestStableDouble { |
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(DoubleStable.class); |
67 run(DoubleStable.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 double[1]; c.v[0] = 1.0; double val1 = get(); |
181 c.v = new double[1]; c.v[0] = 1.0; double val1 = get(); |
183 c.v[0] = 2.0; double val2 = get(); |
182 c.v[0] = 2.0; double val2 = get(); |
184 assertEquals(val1, 1.0); |
183 assertEquals(val1, 1.0); |
185 assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); |
184 assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
186 |
185 |
187 c.v = new double[1]; c.v[0] = 3.0; double val3 = get(); |
186 c.v = new double[1]; c.v[0] = 3.0; double val3 = get(); |
188 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
187 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
189 : 3.0)); |
188 : 3.0)); |
190 } |
189 } |
191 |
190 |
192 { |
191 { |
193 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1(); |
192 c.v = new double[20]; c.v[10] = 1.0; double val1 = get1(); |
194 c.v[10] = 2.0; double val2 = get1(); |
193 c.v[10] = 2.0; double val2 = get1(); |
195 assertEquals(val1, 1.0); |
194 assertEquals(val1, 1.0); |
196 assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); |
195 assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
197 |
196 |
198 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1(); |
197 c.v = new double[20]; c.v[10] = 3.0; double val3 = get1(); |
199 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
198 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
200 : 3.0)); |
199 : 3.0)); |
201 } |
200 } |
202 |
201 |
203 { |
202 { |
204 c.v = new double[1]; double[] val1 = get2(); |
203 c.v = new double[1]; double[] val1 = get2(); |
220 public static void test() throws Exception { |
219 public static void test() throws Exception { |
221 { |
220 { |
222 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get(); |
221 c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get(); |
223 c.v[0][0] = 2.0; double val2 = get(); |
222 c.v[0][0] = 2.0; double val2 = get(); |
224 assertEquals(val1, 1.0); |
223 assertEquals(val1, 1.0); |
225 assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); |
224 assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
226 |
225 |
227 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get(); |
226 c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get(); |
228 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
227 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
229 : 3.0)); |
228 : 3.0)); |
230 |
229 |
231 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get(); |
230 c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get(); |
232 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
231 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
233 : 4.0)); |
232 : 4.0)); |
234 } |
233 } |
235 |
234 |
236 { |
235 { |
237 c.v = new double[1][1]; double[] val1 = get1(); |
236 c.v = new double[1][1]; double[] val1 = get1(); |
238 c.v[0] = new double[1]; double[] val2 = get1(); |
237 c.v[0] = new double[1]; double[] 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 double[1][1]; double[][] val1 = get2(); |
242 c.v = new double[1][1]; double[][] val1 = get2(); |
244 c.v = new double[1][1]; double[][] val2 = get2(); |
243 c.v = new double[1][1]; double[][] val2 = get2(); |
260 public static void test() throws Exception { |
259 public static void test() throws Exception { |
261 { |
260 { |
262 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get(); |
261 c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get(); |
263 c.v[0][0][0] = 2.0; double val2 = get(); |
262 c.v[0][0][0] = 2.0; double val2 = get(); |
264 assertEquals(val1, 1.0); |
263 assertEquals(val1, 1.0); |
265 assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); |
264 assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
266 |
265 |
267 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get(); |
266 c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get(); |
268 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
267 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
269 : 3.0)); |
268 : 3.0)); |
270 |
269 |
271 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get(); |
270 c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get(); |
272 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
271 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
273 : 4.0)); |
272 : 4.0)); |
274 |
273 |
275 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get(); |
274 c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get(); |
276 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
275 assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
277 : 5.0)); |
276 : 5.0)); |
278 } |
277 } |
279 |
278 |
280 { |
279 { |
281 c.v = new double[1][1][1]; double[] val1 = get1(); |
280 c.v = new double[1][1][1]; double[] val1 = get1(); |
282 c.v[0][0] = new double[1]; double[] val2 = get1(); |
281 c.v[0][0] = new double[1]; double[] 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 double[1][1][1]; double[][] val1 = get2(); |
286 c.v = new double[1][1][1]; double[][] val1 = get2(); |
288 c.v[0] = new double[1][1]; double[][] val2 = get2(); |
287 c.v[0] = new double[1][1]; double[][] 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 double[1][1][1]; double[][][] val1 = get3(); |
292 c.v = new double[1][1][1]; double[][][] val1 = get3(); |
294 c.v = new double[1][1][1]; double[][][] val2 = get3(); |
293 c.v = new double[1][1][1]; double[][][] val2 = get3(); |
311 public static void test() throws Exception { |
310 public static void test() throws Exception { |
312 { |
311 { |
313 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get(); |
312 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get(); |
314 c.v[0][0][0][0] = 2.0; double val2 = get(); |
313 c.v[0][0][0][0] = 2.0; double val2 = get(); |
315 assertEquals(val1, 1.0); |
314 assertEquals(val1, 1.0); |
316 assertEquals(val2, (isServerWithStable ? 1.0 : 2.0)); |
315 assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
317 |
316 |
318 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get(); |
317 c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get(); |
319 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
318 assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
320 : 3.0)); |
319 : 3.0)); |
321 |
320 |
322 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get(); |
321 c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get(); |
323 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
322 assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
324 : 4.0)); |
323 : 4.0)); |
325 |
324 |
326 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get(); |
325 c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get(); |
327 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
326 assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
328 : 5.0)); |
327 : 5.0)); |
329 |
328 |
330 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get(); |
329 c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get(); |
331 assertEquals(val6, (isStableEnabled ? (isServerWithStable ? 1.0 : 2.0) |
330 assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
332 : 6.0)); |
331 : 6.0)); |
333 } |
332 } |
334 |
333 |
335 { |
334 { |
336 c.v = new double[1][1][1][1]; double[] val1 = get1(); |
335 c.v = new double[1][1][1][1]; double[] val1 = get1(); |
337 c.v[0][0][0] = new double[1]; double[] val2 = get1(); |
336 c.v[0][0][0] = new double[1]; double[] 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 double[1][1][1][1]; double[][] val1 = get2(); |
341 c.v = new double[1][1][1][1]; double[][] val1 = get2(); |
343 c.v[0][0] = new double[1][1]; double[][] val2 = get2(); |
342 c.v[0][0] = new double[1][1]; double[][] 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 double[1][1][1][1]; double[][][] val1 = get3(); |
347 c.v = new double[1][1][1][1]; double[][][] val1 = get3(); |
349 c.v[0] = new double[1][1][1]; double[][][] val2 = get3(); |
348 c.v[0] = new double[1][1][1]; double[][][] 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 double[1][1][1][1]; double[][][][] val1 = get4(); |
353 c.v = new double[1][1][1][1]; double[][][][] val1 = get4(); |
355 c.v = new double[1][1][1][1]; double[][][][] val2 = get4(); |
354 c.v = new double[1][1][1][1]; double[][][][] val2 = get4(); |
441 |
440 |
442 { |
441 { |
443 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1(); |
442 c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1(); |
444 c.v[0][0] = new double[0]; double[] val2 = get1(); |
443 c.v[0][0] = new double[0]; double[] 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 double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2(); |
449 c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2(); |
451 c.v[0] = new double[0][0]; double[][] val2 = get2(); |
450 c.v[0] = new double[0][0]; double[][] 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 double[0][0][0]; Object[][] val1 = get3(); |
456 c.v = new double[0][0][0]; Object[][] val1 = get3(); |
458 c.v = new double[0][0][0]; Object[][] val2 = get3(); |
457 c.v = new double[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.0; double val1 = get(); double val2 = get1(); |
583 elem.a = 1.0; double val1 = get(); double val2 = get1(); |
585 elem.a = 2.0; double val3 = get(); double val4 = get1(); |
584 elem.a = 2.0; double val3 = get(); double val4 = get1(); |
586 |
585 |
587 assertEquals(val1, 1.0); |
586 assertEquals(val1, 1.0); |
588 assertEquals(val3, (isServerWithStable ? 1.0 : 2.0)); |
587 assertEquals(val3, (isStableEnabled ? 1.0 : 2.0)); |
589 |
588 |
590 assertEquals(val2, 1.0); |
589 assertEquals(val2, 1.0); |
591 assertEquals(val4, 2.0); |
590 assertEquals(val4, 2.0); |
592 } |
591 } |
593 } |
592 } |