427 return desc;
428 }
429 }
430
431 static class VarHandleAccessTestCase extends AccessTestCase<VarHandle> {
432 final VarHandle vh;
433
434 VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata) {
435 this(desc, vh, ata, true);
436 }
437
438 VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata, boolean loop) {
439 super("VarHandle -> " + desc, ata, loop);
440 this.vh = vh;
441 }
442
443 @Override
444 VarHandle get() {
445 return vh;
446 }
447 }
448
449 static class MethodHandleAccessTestCase extends AccessTestCase<Handles> {
450 final VarHandle vh;
451 final VarHandleToMethodHandle f;
452
453 MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata) {
454 this(desc, vh, f, ata, true);
455 }
456
457 MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata, boolean loop) {
458 super("VarHandle -> " + f.toString() + " -> " + desc, ata, loop);
459 this.vh = vh;
460 this.f = f;
461 }
462
463 @Override
464 Handles get() throws Exception {
465 return new Handles(vh, f);
466 }
467 }
468
469 static void testTypes(VarHandle vh) {
470 List<Class<?>> pts = vh.coordinateTypes();
471
472 for (TestAccessMode accessMode : testAccessModes()) {
473 MethodType amt = vh.accessModeType(accessMode.toAccessMode());
474
475 assertEquals(amt.parameterList().subList(0, pts.size()), pts);
476 }
477
478 for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET)) {
479 MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
480 assertEquals(mt.returnType(), vh.varType());
481 assertEquals(mt.parameterList(), pts);
482 }
483
484 for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.SET)) {
485 MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
486 assertEquals(mt.returnType(), void.class);
|
427 return desc;
428 }
429 }
430
431 static class VarHandleAccessTestCase extends AccessTestCase<VarHandle> {
432 final VarHandle vh;
433
434 VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata) {
435 this(desc, vh, ata, true);
436 }
437
438 VarHandleAccessTestCase(String desc, VarHandle vh, AccessTestAction<VarHandle> ata, boolean loop) {
439 super("VarHandle -> " + desc, ata, loop);
440 this.vh = vh;
441 }
442
443 @Override
444 VarHandle get() {
445 return vh;
446 }
447
448 public String toString() {
449 return super.toString() + ", vh:" + vh;
450 }
451 }
452
453 static class MethodHandleAccessTestCase extends AccessTestCase<Handles> {
454 final VarHandle vh;
455 final VarHandleToMethodHandle f;
456
457 MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata) {
458 this(desc, vh, f, ata, true);
459 }
460
461 MethodHandleAccessTestCase(String desc, VarHandle vh, VarHandleToMethodHandle f, AccessTestAction<Handles> ata, boolean loop) {
462 super("VarHandle -> " + f.toString() + " -> " + desc, ata, loop);
463 this.vh = vh;
464 this.f = f;
465 }
466
467 @Override
468 Handles get() throws Exception {
469 return new Handles(vh, f);
470 }
471
472 public String toString() {
473 return super.toString() + ", vh:" + vh + ", f: " + f;
474 }
475 }
476
477 static void testTypes(VarHandle vh) {
478 List<Class<?>> pts = vh.coordinateTypes();
479
480 for (TestAccessMode accessMode : testAccessModes()) {
481 MethodType amt = vh.accessModeType(accessMode.toAccessMode());
482
483 assertEquals(amt.parameterList().subList(0, pts.size()), pts);
484 }
485
486 for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.GET)) {
487 MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
488 assertEquals(mt.returnType(), vh.varType());
489 assertEquals(mt.parameterList(), pts);
490 }
491
492 for (TestAccessMode testAccessMode : testAccessModesOfType(TestAccessType.SET)) {
493 MethodType mt = vh.accessModeType(testAccessMode.toAccessMode());
494 assertEquals(mt.returnType(), void.class);
|