< prev index next >

test/jdk/java/lang/invoke/VarHandles/VarHandleBaseTest.java

Print this page
rev 55900 : 8207257: Add VarHandle access test for value type declared in ref type
Reviewed-by: tbd


 410             return desc;
 411         }
 412     }
 413 
 414     static class VarHandleAccessTestCase extends AccessTestCase<VarHandle> {
 415         final VarHandle vh;
 416 
 417         VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata) {
 418             this(desc, vh, ata, true);
 419         }
 420 
 421         VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata, boolean loop) {
 422             super("VarHandle -> " + desc, ata, loop);
 423             this.vh = vh;
 424         }
 425 
 426         @Override
 427         VarHandle get() {
 428             return vh;
 429         }




 430     }
 431 
 432     static class MethodHandleAccessTestCase extends AccessTestCase<Handles> {
 433         final VarHandle vh;
 434         final VarHandleToMethodHandle f;
 435 
 436         MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata) {
 437             this(desc, vh, f, ata, true);
 438         }
 439 
 440         MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata, boolean loop) {
 441             super("VarHandle -> " + f.toString() + " -> " + desc, ata, loop);
 442             this.vh = vh;
 443             this.f = f;
 444         }
 445 
 446         @Override
 447         Handles get() throws Exception {
 448             return new Handles(vh, f);




 449         }
 450     }
 451 
 452     static void testTypes(VarHandle vh) {
 453         List<Class<?>> pts = vh.coordinateTypes();
 454 
 455         for (TestAccessMode accessMode : testAccessModes()) {
 456             MethodType amt = vh.accessModeType(accessMode.toAccessMode());
 457 
 458             assertEquals(amt.parameterList().subList(0, pts.size()), pts);
 459         }
 460 
 461         for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET)) {
 462             MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
 463             assertEquals(mt.returnType(), vh.varType());
 464             assertEquals(mt.parameterList(), pts);
 465         }
 466 
 467         for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.SET)) {
 468             MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());




 410             return desc;
 411         }
 412     }
 413 
 414     static class VarHandleAccessTestCase extends AccessTestCase<VarHandle> {
 415         final VarHandle vh;
 416 
 417         VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata) {
 418             this(desc, vh, ata, true);
 419         }
 420 
 421         VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata, boolean loop) {
 422             super("VarHandle -> " + desc, ata, loop);
 423             this.vh = vh;
 424         }
 425 
 426         @Override
 427         VarHandle get() {
 428             return vh;
 429         }
 430 
 431         public String toString() {
 432             return super.toString() + ", vh:" + vh;
 433         }
 434     }
 435 
 436     static class MethodHandleAccessTestCase extends AccessTestCase<Handles> {
 437         final VarHandle vh;
 438         final VarHandleToMethodHandle f;
 439 
 440         MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata) {
 441             this(desc, vh, f, ata, true);
 442         }
 443 
 444         MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata, boolean loop) {
 445             super("VarHandle -> " + f.toString() + " -> " + desc, ata, loop);
 446             this.vh = vh;
 447             this.f = f;
 448         }
 449 
 450         @Override
 451         Handles get() throws Exception {
 452             return new Handles(vh, f);
 453         }
 454 
 455         public String toString() {
 456             return super.toString() + ", vh:" + vh + ", f: " + f;
 457         }
 458     }
 459 
 460     static void testTypes(VarHandle vh) {
 461         List<Class<?>> pts = vh.coordinateTypes();
 462 
 463         for (TestAccessMode accessMode : testAccessModes()) {
 464             MethodType amt = vh.accessModeType(accessMode.toAccessMode());
 465 
 466             assertEquals(amt.parameterList().subList(0, pts.size()), pts);
 467         }
 468 
 469         for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET)) {
 470             MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
 471             assertEquals(mt.returnType(), vh.varType());
 472             assertEquals(mt.parameterList(), pts);
 473         }
 474 
 475         for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.SET)) {
 476             MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());


< prev index next >