< prev index next >

test/hotspot/jtreg/compiler/valhalla/valuetypes/TestNullableValueTypes.java

Print this page




 658             // Expected
 659         }
 660     }
 661 
 662     static MyValue1.box nullBox;
 663 
 664     @Test
 665     public MyValue1 test24() {
 666         return nullBox;
 667     }
 668 
 669     @DontCompile
 670     public void test24_verifier(boolean warmup) {
 671         try {
 672             test24();
 673             throw new RuntimeException("NullPointerException expected");
 674         } catch (NullPointerException e) {
 675             // Expected
 676         }
 677     }





















 678 }


 658             // Expected
 659         }
 660     }
 661 
 662     static MyValue1.box nullBox;
 663 
 664     @Test
 665     public MyValue1 test24() {
 666         return nullBox;
 667     }
 668 
 669     @DontCompile
 670     public void test24_verifier(boolean warmup) {
 671         try {
 672             test24();
 673             throw new RuntimeException("NullPointerException expected");
 674         } catch (NullPointerException e) {
 675             // Expected
 676         }
 677     }
 678 
 679     @DontInline
 680     public void test25_callee(MyValue1 val) { }
 681 
 682     // Test that when checkcasting from .box to .val and back to .box we
 683     // keep track of the information that the value can never be null.
 684     @Test(failOn = ALLOC + STORE)
 685     public int test25(boolean b, MyValue1.box vt1, MyValue1.val vt2) {
 686         vt1 = (MyValue1.val)vt1;
 687         Object obj = b ? vt1 : vt2; // We should not allocate here
 688         test25_callee(vt1);
 689         return ((MyValue1)obj).x;
 690     }
 691 
 692     @DontCompile
 693     public void test25_verifier(boolean warmup) {
 694         int res = test25(true, testValue1, testValue1);
 695         Asserts.assertEquals(res, testValue1.x);
 696         res = test25(false, testValue1, testValue1);
 697         Asserts.assertEquals(res, testValue1.x);
 698     }
 699 }
< prev index next >