< prev index next >

test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java

Print this page




 305             vh.setRelease(null, true);
 306         });
 307         checkCCE(() -> { // receiver reference class
 308             vh.setRelease(Void.class, true);
 309         });
 310         checkWMTE(() -> { // value reference class
 311             vh.setRelease(recv, Void.class);
 312         });
 313         checkWMTE(() -> { // receiver primitive class
 314             vh.setRelease(0, true);
 315         });
 316         // Incorrect arity
 317         checkWMTE(() -> { // 0
 318             vh.setRelease();
 319         });
 320         checkWMTE(() -> { // >
 321             vh.setRelease(recv, true, Void.class);
 322         });
 323 
 324 

































































































































































































































































 325 
 326     }
 327 
 328     static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeBoolean recv, Handles hs) throws Throwable {
 329         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
 330             // Incorrect argument types
 331             checkNPE(() -> { // null receiver
 332                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)).
 333                     invoke(null);
 334             });
 335             checkCCE(() -> { // receiver reference class
 336                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
 337                     invoke(Void.class);
 338             });
 339             checkWMTE(() -> { // receiver primitive class
 340                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
 341                     invoke(0);
 342             });
 343             // Incorrect return type
 344             checkWMTE(() -> { // reference class


 372             });
 373             checkWMTE(() -> { // value reference class
 374                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
 375                     invoke(recv, Void.class);
 376             });
 377             checkWMTE(() -> { // receiver primitive class
 378                 hs.get(am, methodType(void.class, int.class, boolean.class)).
 379                     invoke(0, true);
 380             });
 381             // Incorrect arity
 382             checkWMTE(() -> { // 0
 383                 hs.get(am, methodType(void.class)).
 384                     invoke();
 385             });
 386             checkWMTE(() -> { // >
 387                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
 388                     invoke(recv, true, Void.class);
 389             });
 390         }
 391 














































































































 392 
 393     }
 394 
 395 
 396     static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable {
 397         // Get
 398         // Incorrect return type
 399         checkWMTE(() -> { // reference class
 400             Void x = (Void) vh.get();
 401         });
 402         checkWMTE(() -> { // primitive class
 403             int x = (int) vh.get();
 404         });
 405         // Incorrect arity
 406         checkWMTE(() -> { // >
 407             boolean x = (boolean) vh.get(Void.class);
 408         });
 409 
 410 
 411         // Set


 486         });
 487         checkWMTE(() -> { // >
 488             boolean x = (boolean) vh.getAcquire(Void.class);
 489         });
 490 
 491 
 492         // SetRelease
 493         // Incorrect argument types
 494         checkWMTE(() -> { // value reference class
 495             vh.setRelease(Void.class);
 496         });
 497         // Incorrect arity
 498         checkWMTE(() -> { // 0
 499             vh.setRelease();
 500         });
 501         checkWMTE(() -> { // >
 502             vh.setRelease(true, Void.class);
 503         });
 504 
 505 
















































































































































































 506 
 507     }
 508 
 509     static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
 510         int i = 0;
 511 
 512         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
 513             // Incorrect return type
 514             checkWMTE(() -> { // reference class
 515                 Void x = (Void) hs.get(am, methodType(Void.class)).
 516                     invoke();
 517             });
 518             checkWMTE(() -> { // primitive class
 519                 int x = (int) hs.get(am, methodType(int.class)).
 520                     invoke();
 521             });
 522             // Incorrect arity
 523             checkWMTE(() -> { // >
 524                 boolean x = (boolean) hs.get(am, methodType(Class.class)).
 525                     invoke(Void.class);
 526             });
 527         }
 528 
 529         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
 530             checkWMTE(() -> { // value reference class
 531                 hs.get(am, methodType(void.class, Class.class)).
 532                     invoke(Void.class);
 533             });
 534             // Incorrect arity
 535             checkWMTE(() -> { // 0
 536                 hs.get(am, methodType(void.class)).












































































 537                     invoke();
 538             });
 539             checkWMTE(() -> { // >
 540                 hs.get(am, methodType(void.class, boolean.class, Class.class)).
 541                     invoke(true, Void.class);
 542             });
 543         }
 544 
 545     }
 546 
 547 
 548     static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
 549         boolean[] array = new boolean[10];
 550         Arrays.fill(array, true);
 551 
 552         // Get
 553         // Incorrect argument types
 554         checkNPE(() -> { // null array
 555             boolean x = (boolean) vh.get(null, 0);
 556         });
 557         checkCCE(() -> { // array reference class
 558             boolean x = (boolean) vh.get(Void.class, 0);
 559         });
 560         checkWMTE(() -> { // array primitive class


 756             vh.setRelease(Void.class, 0, true);
 757         });
 758         checkWMTE(() -> { // value reference class
 759             vh.setRelease(array, 0, Void.class);
 760         });
 761         checkWMTE(() -> { // receiver primitive class
 762             vh.setRelease(0, 0, true);
 763         });
 764         checkWMTE(() -> { // index reference class
 765             vh.setRelease(array, Void.class, true);
 766         });
 767         // Incorrect arity
 768         checkWMTE(() -> { // 0
 769             vh.setRelease();
 770         });
 771         checkWMTE(() -> { // >
 772             vh.setRelease(array, 0, true, Void.class);
 773         });
 774 
 775 




























































































































































































































































































 776 
 777     }
 778 
 779     static void testArrayWrongMethodType(Handles hs) throws Throwable {
 780         boolean[] array = new boolean[10];
 781         Arrays.fill(array, true);
 782 
 783         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
 784             // Incorrect argument types
 785             checkNPE(() -> { // null array
 786                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)).
 787                     invoke(null, 0);
 788             });
 789             checkCCE(() -> { // array reference class
 790                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
 791                     invoke(Void.class, 0);
 792             });
 793             checkWMTE(() -> { // array primitive class
 794                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
 795                     invoke(0, 0);


 830             });
 831             checkWMTE(() -> { // value reference class
 832                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
 833                     invoke(array, 0, Void.class);
 834             });
 835             checkWMTE(() -> { // receiver primitive class
 836                 hs.get(am, methodType(void.class, int.class, int.class, boolean.class)).
 837                     invoke(0, 0, true);
 838             });
 839             checkWMTE(() -> { // index reference class
 840                 hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)).
 841                     invoke(array, Void.class, true);
 842             });
 843             // Incorrect arity
 844             checkWMTE(() -> { // 0
 845                 hs.get(am, methodType(void.class)).
 846                     invoke();
 847             });
 848             checkWMTE(() -> { // >
 849                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).




























































































































 850                     invoke(array, 0, true, Void.class);
 851             });
 852         }
 853 
 854     }
 855 }
 856 


 305             vh.setRelease(null, true);
 306         });
 307         checkCCE(() -> { // receiver reference class
 308             vh.setRelease(Void.class, true);
 309         });
 310         checkWMTE(() -> { // value reference class
 311             vh.setRelease(recv, Void.class);
 312         });
 313         checkWMTE(() -> { // receiver primitive class
 314             vh.setRelease(0, true);
 315         });
 316         // Incorrect arity
 317         checkWMTE(() -> { // 0
 318             vh.setRelease();
 319         });
 320         checkWMTE(() -> { // >
 321             vh.setRelease(recv, true, Void.class);
 322         });
 323 
 324 
 325         // CompareAndSet
 326         // Incorrect argument types
 327         checkNPE(() -> { // null receiver
 328             boolean r = vh.compareAndSet(null, true, true);
 329         });
 330         checkCCE(() -> { // receiver reference class
 331             boolean r = vh.compareAndSet(Void.class, true, true);
 332         });
 333         checkWMTE(() -> { // expected reference class
 334             boolean r = vh.compareAndSet(recv, Void.class, true);
 335         });
 336         checkWMTE(() -> { // actual reference class
 337             boolean r = vh.compareAndSet(recv, true, Void.class);
 338         });
 339         checkWMTE(() -> { // receiver primitive class
 340             boolean r = vh.compareAndSet(0, true, true);
 341         });
 342         // Incorrect arity
 343         checkWMTE(() -> { // 0
 344             boolean r = vh.compareAndSet();
 345         });
 346         checkWMTE(() -> { // >
 347             boolean r = vh.compareAndSet(recv, true, true, Void.class);
 348         });
 349 
 350 
 351         // WeakCompareAndSet
 352         // Incorrect argument types
 353         checkNPE(() -> { // null receiver
 354             boolean r = vh.weakCompareAndSet(null, true, true);
 355         });
 356         checkCCE(() -> { // receiver reference class
 357             boolean r = vh.weakCompareAndSet(Void.class, true, true);
 358         });
 359         checkWMTE(() -> { // expected reference class
 360             boolean r = vh.weakCompareAndSet(recv, Void.class, true);
 361         });
 362         checkWMTE(() -> { // actual reference class
 363             boolean r = vh.weakCompareAndSet(recv, true, Void.class);
 364         });
 365         checkWMTE(() -> { // receiver primitive class
 366             boolean r = vh.weakCompareAndSet(0, true, true);
 367         });
 368         // Incorrect arity
 369         checkWMTE(() -> { // 0
 370             boolean r = vh.weakCompareAndSet();
 371         });
 372         checkWMTE(() -> { // >
 373             boolean r = vh.weakCompareAndSet(recv, true, true, Void.class);
 374         });
 375 
 376 
 377         // WeakCompareAndSetVolatile
 378         // Incorrect argument types
 379         checkNPE(() -> { // null receiver
 380             boolean r = vh.weakCompareAndSetVolatile(null, true, true);
 381         });
 382         checkCCE(() -> { // receiver reference class
 383             boolean r = vh.weakCompareAndSetVolatile(Void.class, true, true);
 384         });
 385         checkWMTE(() -> { // expected reference class
 386             boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, true);
 387         });
 388         checkWMTE(() -> { // actual reference class
 389             boolean r = vh.weakCompareAndSetVolatile(recv, true, Void.class);
 390         });
 391         checkWMTE(() -> { // receiver primitive class
 392             boolean r = vh.weakCompareAndSetVolatile(0, true, true);
 393         });
 394         // Incorrect arity
 395         checkWMTE(() -> { // 0
 396             boolean r = vh.weakCompareAndSetVolatile();
 397         });
 398         checkWMTE(() -> { // >
 399             boolean r = vh.weakCompareAndSetVolatile(recv, true, true, Void.class);
 400         });
 401 
 402 
 403         // WeakCompareAndSetAcquire
 404         // Incorrect argument types
 405         checkNPE(() -> { // null receiver
 406             boolean r = vh.weakCompareAndSetAcquire(null, true, true);
 407         });
 408         checkCCE(() -> { // receiver reference class
 409             boolean r = vh.weakCompareAndSetAcquire(Void.class, true, true);
 410         });
 411         checkWMTE(() -> { // expected reference class
 412             boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, true);
 413         });
 414         checkWMTE(() -> { // actual reference class
 415             boolean r = vh.weakCompareAndSetAcquire(recv, true, Void.class);
 416         });
 417         checkWMTE(() -> { // receiver primitive class
 418             boolean r = vh.weakCompareAndSetAcquire(0, true, true);
 419         });
 420         // Incorrect arity
 421         checkWMTE(() -> { // 0
 422             boolean r = vh.weakCompareAndSetAcquire();
 423         });
 424         checkWMTE(() -> { // >
 425             boolean r = vh.weakCompareAndSetAcquire(recv, true, true, Void.class);
 426         });
 427 
 428 
 429         // WeakCompareAndSetRelease
 430         // Incorrect argument types
 431         checkNPE(() -> { // null receiver
 432             boolean r = vh.weakCompareAndSetRelease(null, true, true);
 433         });
 434         checkCCE(() -> { // receiver reference class
 435             boolean r = vh.weakCompareAndSetRelease(Void.class, true, true);
 436         });
 437         checkWMTE(() -> { // expected reference class
 438             boolean r = vh.weakCompareAndSetRelease(recv, Void.class, true);
 439         });
 440         checkWMTE(() -> { // actual reference class
 441             boolean r = vh.weakCompareAndSetRelease(recv, true, Void.class);
 442         });
 443         checkWMTE(() -> { // receiver primitive class
 444             boolean r = vh.weakCompareAndSetRelease(0, true, true);
 445         });
 446         // Incorrect arity
 447         checkWMTE(() -> { // 0
 448             boolean r = vh.weakCompareAndSetRelease();
 449         });
 450         checkWMTE(() -> { // >
 451             boolean r = vh.weakCompareAndSetRelease(recv, true, true, Void.class);
 452         });
 453 
 454 
 455         // CompareAndExchangeVolatile
 456         // Incorrect argument types
 457         checkNPE(() -> { // null receiver
 458             boolean x = (boolean) vh.compareAndExchangeVolatile(null, true, true);
 459         });
 460         checkCCE(() -> { // receiver reference class
 461             boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, true, true);
 462         });
 463         checkWMTE(() -> { // expected reference class
 464             boolean x = (boolean) vh.compareAndExchangeVolatile(recv, Void.class, true);
 465         });
 466         checkWMTE(() -> { // actual reference class
 467             boolean x = (boolean) vh.compareAndExchangeVolatile(recv, true, Void.class);
 468         });
 469         checkWMTE(() -> { // reciever primitive class
 470             boolean x = (boolean) vh.compareAndExchangeVolatile(0, true, true);
 471         });
 472         // Incorrect return type
 473         checkWMTE(() -> { // reference class
 474             Void r = (Void) vh.compareAndExchangeVolatile(recv, true, true);
 475         });
 476         checkWMTE(() -> { // primitive class
 477             int x = (int) vh.compareAndExchangeVolatile(recv, true, true);
 478         });
 479         // Incorrect arity
 480         checkWMTE(() -> { // 0
 481             boolean x = (boolean) vh.compareAndExchangeVolatile();
 482         });
 483         checkWMTE(() -> { // >
 484             boolean x = (boolean) vh.compareAndExchangeVolatile(recv, true, true, Void.class);
 485         });
 486 
 487 
 488         // CompareAndExchangeVolatileAcquire
 489         // Incorrect argument types
 490         checkNPE(() -> { // null receiver
 491             boolean x = (boolean) vh.compareAndExchangeAcquire(null, true, true);
 492         });
 493         checkCCE(() -> { // receiver reference class
 494             boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, true, true);
 495         });
 496         checkWMTE(() -> { // expected reference class
 497             boolean x = (boolean) vh.compareAndExchangeAcquire(recv, Void.class, true);
 498         });
 499         checkWMTE(() -> { // actual reference class
 500             boolean x = (boolean) vh.compareAndExchangeAcquire(recv, true, Void.class);
 501         });
 502         checkWMTE(() -> { // reciever primitive class
 503             boolean x = (boolean) vh.compareAndExchangeAcquire(0, true, true);
 504         });
 505         // Incorrect return type
 506         checkWMTE(() -> { // reference class
 507             Void r = (Void) vh.compareAndExchangeAcquire(recv, true, true);
 508         });
 509         checkWMTE(() -> { // primitive class
 510             int x = (int) vh.compareAndExchangeAcquire(recv, true, true);
 511         });
 512         // Incorrect arity
 513         checkWMTE(() -> { // 0
 514             boolean x = (boolean) vh.compareAndExchangeAcquire();
 515         });
 516         checkWMTE(() -> { // >
 517             boolean x = (boolean) vh.compareAndExchangeAcquire(recv, true, true, Void.class);
 518         });
 519 
 520 
 521         // CompareAndExchangeRelease
 522         // Incorrect argument types
 523         checkNPE(() -> { // null receiver
 524             boolean x = (boolean) vh.compareAndExchangeRelease(null, true, true);
 525         });
 526         checkCCE(() -> { // receiver reference class
 527             boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, true, true);
 528         });
 529         checkWMTE(() -> { // expected reference class
 530             boolean x = (boolean) vh.compareAndExchangeRelease(recv, Void.class, true);
 531         });
 532         checkWMTE(() -> { // actual reference class
 533             boolean x = (boolean) vh.compareAndExchangeRelease(recv, true, Void.class);
 534         });
 535         checkWMTE(() -> { // reciever primitive class
 536             boolean x = (boolean) vh.compareAndExchangeRelease(0, true, true);
 537         });
 538         // Incorrect return type
 539         checkWMTE(() -> { // reference class
 540             Void r = (Void) vh.compareAndExchangeRelease(recv, true, true);
 541         });
 542         checkWMTE(() -> { // primitive class
 543             int x = (int) vh.compareAndExchangeRelease(recv, true, true);
 544         });
 545         // Incorrect arity
 546         checkWMTE(() -> { // 0
 547             boolean x = (boolean) vh.compareAndExchangeRelease();
 548         });
 549         checkWMTE(() -> { // >
 550             boolean x = (boolean) vh.compareAndExchangeRelease(recv, true, true, Void.class);
 551         });
 552 
 553 
 554         // GetAndSet
 555         // Incorrect argument types
 556         checkNPE(() -> { // null receiver
 557             boolean x = (boolean) vh.getAndSet(null, true);
 558         });
 559         checkCCE(() -> { // receiver reference class
 560             boolean x = (boolean) vh.getAndSet(Void.class, true);
 561         });
 562         checkWMTE(() -> { // value reference class
 563             boolean x = (boolean) vh.getAndSet(recv, Void.class);
 564         });
 565         checkWMTE(() -> { // reciever primitive class
 566             boolean x = (boolean) vh.getAndSet(0, true);
 567         });
 568         // Incorrect return type
 569         checkWMTE(() -> { // reference class
 570             Void r = (Void) vh.getAndSet(recv, true);
 571         });
 572         checkWMTE(() -> { // primitive class
 573             int x = (int) vh.getAndSet(recv, true);
 574         });
 575         // Incorrect arity
 576         checkWMTE(() -> { // 0
 577             boolean x = (boolean) vh.getAndSet();
 578         });
 579         checkWMTE(() -> { // >
 580             boolean x = (boolean) vh.getAndSet(recv, true, Void.class);
 581         });
 582 
 583     }
 584 
 585     static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeBoolean recv, Handles hs) throws Throwable {
 586         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
 587             // Incorrect argument types
 588             checkNPE(() -> { // null receiver
 589                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)).
 590                     invoke(null);
 591             });
 592             checkCCE(() -> { // receiver reference class
 593                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
 594                     invoke(Void.class);
 595             });
 596             checkWMTE(() -> { // receiver primitive class
 597                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
 598                     invoke(0);
 599             });
 600             // Incorrect return type
 601             checkWMTE(() -> { // reference class


 629             });
 630             checkWMTE(() -> { // value reference class
 631                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
 632                     invoke(recv, Void.class);
 633             });
 634             checkWMTE(() -> { // receiver primitive class
 635                 hs.get(am, methodType(void.class, int.class, boolean.class)).
 636                     invoke(0, true);
 637             });
 638             // Incorrect arity
 639             checkWMTE(() -> { // 0
 640                 hs.get(am, methodType(void.class)).
 641                     invoke();
 642             });
 643             checkWMTE(() -> { // >
 644                 hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
 645                     invoke(recv, true, Void.class);
 646             });
 647         }
 648 
 649         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
 650             // Incorrect argument types
 651             checkNPE(() -> { // null receiver
 652                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, boolean.class, boolean.class)).
 653                     invoke(null, true, true);
 654             });
 655             checkCCE(() -> { // receiver reference class
 656                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class, boolean.class)).
 657                     invoke(Void.class, true, true);
 658             });
 659             checkWMTE(() -> { // expected reference class
 660                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class, boolean.class)).
 661                     invoke(recv, Void.class, true);
 662             });
 663             checkWMTE(() -> { // actual reference class
 664                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
 665                     invoke(recv, true, Void.class);
 666             });
 667             checkWMTE(() -> { // receiver primitive class
 668                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , boolean.class, boolean.class)).
 669                     invoke(0, true, true);
 670             });
 671             // Incorrect arity
 672             checkWMTE(() -> { // 0
 673                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
 674                     invoke();
 675             });
 676             checkWMTE(() -> { // >
 677                 boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class, Class.class)).
 678                     invoke(recv, true, true, Void.class);
 679             });
 680         }
 681 
 682         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
 683             checkNPE(() -> { // null receiver
 684                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, boolean.class, boolean.class)).
 685                     invoke(null, true, true);
 686             });
 687             checkCCE(() -> { // receiver reference class
 688                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class, boolean.class)).
 689                     invoke(Void.class, true, true);
 690             });
 691             checkWMTE(() -> { // expected reference class
 692                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class, boolean.class)).
 693                     invoke(recv, Void.class, true);
 694             });
 695             checkWMTE(() -> { // actual reference class
 696                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
 697                     invoke(recv, true, Void.class);
 698             });
 699             checkWMTE(() -> { // reciever primitive class
 700                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class , boolean.class, boolean.class)).
 701                     invoke(0, true, true);
 702             });
 703             // Incorrect return type
 704             checkWMTE(() -> { // reference class
 705                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class , boolean.class, boolean.class)).
 706                     invoke(recv, true, true);
 707             });
 708             checkWMTE(() -> { // primitive class
 709                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class , boolean.class, boolean.class)).
 710                     invoke(recv, true, true);
 711             });
 712             // Incorrect arity
 713             checkWMTE(() -> { // 0
 714                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
 715                     invoke();
 716             });
 717             checkWMTE(() -> { // >
 718                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class, Class.class)).
 719                     invoke(recv, true, true, Void.class);
 720             });
 721         }
 722 
 723         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
 724             checkNPE(() -> { // null receiver
 725                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, boolean.class)).
 726                     invoke(null, true);
 727             });
 728             checkCCE(() -> { // receiver reference class
 729                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
 730                     invoke(Void.class, true);
 731             });
 732             checkWMTE(() -> { // value reference class
 733                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
 734                     invoke(recv, Void.class);
 735             });
 736             checkWMTE(() -> { // reciever primitive class
 737                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, boolean.class)).
 738                     invoke(0, true);
 739             });
 740             // Incorrect return type
 741             checkWMTE(() -> { // reference class
 742                 Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
 743                     invoke(recv, true);
 744             });
 745             checkWMTE(() -> { // primitive class
 746                 int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
 747                     invoke(recv, true);
 748             });
 749             // Incorrect arity
 750             checkWMTE(() -> { // 0
 751                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
 752                     invoke();
 753             });
 754             checkWMTE(() -> { // >
 755                 boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
 756                     invoke(recv, true, Void.class);
 757             });
 758         }
 759 
 760     }
 761 
 762 
 763     static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable {
 764         // Get
 765         // Incorrect return type
 766         checkWMTE(() -> { // reference class
 767             Void x = (Void) vh.get();
 768         });
 769         checkWMTE(() -> { // primitive class
 770             int x = (int) vh.get();
 771         });
 772         // Incorrect arity
 773         checkWMTE(() -> { // >
 774             boolean x = (boolean) vh.get(Void.class);
 775         });
 776 
 777 
 778         // Set


 853         });
 854         checkWMTE(() -> { // >
 855             boolean x = (boolean) vh.getAcquire(Void.class);
 856         });
 857 
 858 
 859         // SetRelease
 860         // Incorrect argument types
 861         checkWMTE(() -> { // value reference class
 862             vh.setRelease(Void.class);
 863         });
 864         // Incorrect arity
 865         checkWMTE(() -> { // 0
 866             vh.setRelease();
 867         });
 868         checkWMTE(() -> { // >
 869             vh.setRelease(true, Void.class);
 870         });
 871 
 872 
 873         // CompareAndSet
 874         // Incorrect argument types
 875         checkWMTE(() -> { // expected reference class
 876             boolean r = vh.compareAndSet(Void.class, true);
 877         });
 878         checkWMTE(() -> { // actual reference class
 879             boolean r = vh.compareAndSet(true, Void.class);
 880         });
 881         // Incorrect arity
 882         checkWMTE(() -> { // 0
 883             boolean r = vh.compareAndSet();
 884         });
 885         checkWMTE(() -> { // >
 886             boolean r = vh.compareAndSet(true, true, Void.class);
 887         });
 888 
 889 
 890         // WeakCompareAndSet
 891         // Incorrect argument types
 892         checkWMTE(() -> { // expected reference class
 893             boolean r = vh.weakCompareAndSet(Void.class, true);
 894         });
 895         checkWMTE(() -> { // actual reference class
 896             boolean r = vh.weakCompareAndSet(true, Void.class);
 897         });
 898         // Incorrect arity
 899         checkWMTE(() -> { // 0
 900             boolean r = vh.weakCompareAndSet();
 901         });
 902         checkWMTE(() -> { // >
 903             boolean r = vh.weakCompareAndSet(true, true, Void.class);
 904         });
 905 
 906 
 907         // WeakCompareAndSetVolatile
 908         // Incorrect argument types
 909         checkWMTE(() -> { // expected reference class
 910             boolean r = vh.weakCompareAndSetVolatile(Void.class, true);
 911         });
 912         checkWMTE(() -> { // actual reference class
 913             boolean r = vh.weakCompareAndSetVolatile(true, Void.class);
 914         });
 915         // Incorrect arity
 916         checkWMTE(() -> { // 0
 917             boolean r = vh.weakCompareAndSetVolatile();
 918         });
 919         checkWMTE(() -> { // >
 920             boolean r = vh.weakCompareAndSetVolatile(true, true, Void.class);
 921         });
 922 
 923 
 924         // WeakCompareAndSetAcquire
 925         // Incorrect argument types
 926         checkWMTE(() -> { // expected reference class
 927             boolean r = vh.weakCompareAndSetAcquire(Void.class, true);
 928         });
 929         checkWMTE(() -> { // actual reference class
 930             boolean r = vh.weakCompareAndSetAcquire(true, Void.class);
 931         });
 932         // Incorrect arity
 933         checkWMTE(() -> { // 0
 934             boolean r = vh.weakCompareAndSetAcquire();
 935         });
 936         checkWMTE(() -> { // >
 937             boolean r = vh.weakCompareAndSetAcquire(true, true, Void.class);
 938         });
 939 
 940 
 941         // WeakCompareAndSetRelease
 942         // Incorrect argument types
 943         checkWMTE(() -> { // expected reference class
 944             boolean r = vh.weakCompareAndSetRelease(Void.class, true);
 945         });
 946         checkWMTE(() -> { // actual reference class
 947             boolean r = vh.weakCompareAndSetRelease(true, Void.class);
 948         });
 949         // Incorrect arity
 950         checkWMTE(() -> { // 0
 951             boolean r = vh.weakCompareAndSetRelease();
 952         });
 953         checkWMTE(() -> { // >
 954             boolean r = vh.weakCompareAndSetRelease(true, true, Void.class);
 955         });
 956 
 957 
 958         // CompareAndExchangeVolatile
 959         // Incorrect argument types
 960         checkWMTE(() -> { // expected reference class
 961             boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, true);
 962         });
 963         checkWMTE(() -> { // actual reference class
 964             boolean x = (boolean) vh.compareAndExchangeVolatile(true, Void.class);
 965         });
 966         // Incorrect return type
 967         checkWMTE(() -> { // reference class
 968             Void r = (Void) vh.compareAndExchangeVolatile(true, true);
 969         });
 970         checkWMTE(() -> { // primitive class
 971             int x = (int) vh.compareAndExchangeVolatile(true, true);
 972         });
 973         // Incorrect arity
 974         checkWMTE(() -> { // 0
 975             boolean x = (boolean) vh.compareAndExchangeVolatile();
 976         });
 977         checkWMTE(() -> { // >
 978             boolean x = (boolean) vh.compareAndExchangeVolatile(true, true, Void.class);
 979         });
 980 
 981 
 982         // CompareAndExchangeAcquire
 983         // Incorrect argument types
 984         checkWMTE(() -> { // expected reference class
 985             boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, true);
 986         });
 987         checkWMTE(() -> { // actual reference class
 988             boolean x = (boolean) vh.compareAndExchangeAcquire(true, Void.class);
 989         });
 990         // Incorrect return type
 991         checkWMTE(() -> { // reference class
 992             Void r = (Void) vh.compareAndExchangeAcquire(true, true);
 993         });
 994         checkWMTE(() -> { // primitive class
 995             int x = (int) vh.compareAndExchangeAcquire(true, true);
 996         });
 997         // Incorrect arity
 998         checkWMTE(() -> { // 0
 999             boolean x = (boolean) vh.compareAndExchangeAcquire();
1000         });
1001         checkWMTE(() -> { // >
1002             boolean x = (boolean) vh.compareAndExchangeAcquire(true, true, Void.class);
1003         });
1004 
1005 
1006         // CompareAndExchangeRelease
1007         // Incorrect argument types
1008         checkWMTE(() -> { // expected reference class
1009             boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, true);
1010         });
1011         checkWMTE(() -> { // actual reference class
1012             boolean x = (boolean) vh.compareAndExchangeRelease(true, Void.class);
1013         });
1014         // Incorrect return type
1015         checkWMTE(() -> { // reference class
1016             Void r = (Void) vh.compareAndExchangeRelease(true, true);
1017         });
1018         checkWMTE(() -> { // primitive class
1019             int x = (int) vh.compareAndExchangeRelease(true, true);
1020         });
1021         // Incorrect arity
1022         checkWMTE(() -> { // 0
1023             boolean x = (boolean) vh.compareAndExchangeRelease();
1024         });
1025         checkWMTE(() -> { // >
1026             boolean x = (boolean) vh.compareAndExchangeRelease(true, true, Void.class);
1027         });
1028 
1029 
1030         // GetAndSet
1031         // Incorrect argument types
1032         checkWMTE(() -> { // value reference class
1033             boolean x = (boolean) vh.getAndSet(Void.class);
1034         });
1035         // Incorrect return type
1036         checkWMTE(() -> { // reference class
1037             Void r = (Void) vh.getAndSet(true);
1038         });
1039         checkWMTE(() -> { // primitive class
1040             int x = (int) vh.getAndSet(true);
1041         });
1042         // Incorrect arity
1043         checkWMTE(() -> { // 0
1044             boolean x = (boolean) vh.getAndSet();
1045         });
1046         checkWMTE(() -> { // >
1047             boolean x = (boolean) vh.getAndSet(true, Void.class);
1048         });
1049 
1050     }
1051 
1052     static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
1053         int i = 0;
1054 
1055         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
1056             // Incorrect return type
1057             checkWMTE(() -> { // reference class
1058                 Void x = (Void) hs.get(am, methodType(Void.class)).
1059                     invoke();
1060             });
1061             checkWMTE(() -> { // primitive class
1062                 int x = (int) hs.get(am, methodType(int.class)).
1063                     invoke();
1064             });
1065             // Incorrect arity
1066             checkWMTE(() -> { // >
1067                 boolean x = (boolean) hs.get(am, methodType(Class.class)).
1068                     invoke(Void.class);
1069             });
1070         }
1071 
1072         for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
1073             checkWMTE(() -> { // value reference class
1074                 hs.get(am, methodType(void.class, Class.class)).
1075                     invoke(Void.class);
1076             });
1077             // Incorrect arity
1078             checkWMTE(() -> { // 0
1079                 hs.get(am, methodType(void.class)).
1080                     invoke();
1081             });
1082             checkWMTE(() -> { // >
1083                 hs.get(am, methodType(void.class, boolean.class, Class.class)).
1084                     invoke(true, Void.class);
1085             });
1086         }
1087         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1088             // Incorrect argument types
1089             checkWMTE(() -> { // expected reference class
1090                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
1091                     invoke(Void.class, true);
1092             });
1093             checkWMTE(() -> { // actual reference class
1094                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
1095                     invoke(true, Void.class);
1096             });
1097             // Incorrect arity
1098             checkWMTE(() -> { // 0
1099                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
1100                     invoke();
1101             });
1102             checkWMTE(() -> { // >
1103                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean.class, boolean.class, Class.class)).
1104                     invoke(true, true, Void.class);
1105             });
1106         }
1107 
1108         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1109             // Incorrect argument types
1110             checkWMTE(() -> { // expected reference class
1111                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
1112                     invoke(Void.class, true);
1113             });
1114             checkWMTE(() -> { // actual reference class
1115                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
1116                     invoke(true, Void.class);
1117             });
1118             // Incorrect return type
1119             checkWMTE(() -> { // reference class
1120                 Void r = (Void) hs.get(am, methodType(Void.class, boolean.class, boolean.class)).
1121                     invoke(true, true);
1122             });
1123             checkWMTE(() -> { // primitive class
1124                 int x = (int) hs.get(am, methodType(int.class, boolean.class, boolean.class)).
1125                     invoke(true, true);
1126             });
1127             // Incorrect arity
1128             checkWMTE(() -> { // 0
1129                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
1130                     invoke();
1131             });
1132             checkWMTE(() -> { // >
1133                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, boolean.class, Class.class)).
1134                     invoke(true, true, Void.class);
1135             });
1136         }
1137 
1138         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1139             // Incorrect argument types
1140             checkWMTE(() -> { // value reference class
1141                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
1142                     invoke(Void.class);
1143             });
1144             // Incorrect return type
1145             checkWMTE(() -> { // reference class
1146                 Void r = (Void) hs.get(am, methodType(Void.class, boolean.class)).
1147                     invoke(true);
1148             });
1149             checkWMTE(() -> { // primitive class
1150                 int x = (int) hs.get(am, methodType(int.class, boolean.class)).
1151                     invoke(true);
1152             });
1153             // Incorrect arity
1154             checkWMTE(() -> { // 0
1155                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
1156                     invoke();
1157             });
1158             checkWMTE(() -> { // >
1159                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
1160                     invoke(true, Void.class);
1161             });
1162         }
1163 
1164     }
1165 
1166 
1167     static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
1168         boolean[] array = new boolean[10];
1169         Arrays.fill(array, true);
1170 
1171         // Get
1172         // Incorrect argument types
1173         checkNPE(() -> { // null array
1174             boolean x = (boolean) vh.get(null, 0);
1175         });
1176         checkCCE(() -> { // array reference class
1177             boolean x = (boolean) vh.get(Void.class, 0);
1178         });
1179         checkWMTE(() -> { // array primitive class


1375             vh.setRelease(Void.class, 0, true);
1376         });
1377         checkWMTE(() -> { // value reference class
1378             vh.setRelease(array, 0, Void.class);
1379         });
1380         checkWMTE(() -> { // receiver primitive class
1381             vh.setRelease(0, 0, true);
1382         });
1383         checkWMTE(() -> { // index reference class
1384             vh.setRelease(array, Void.class, true);
1385         });
1386         // Incorrect arity
1387         checkWMTE(() -> { // 0
1388             vh.setRelease();
1389         });
1390         checkWMTE(() -> { // >
1391             vh.setRelease(array, 0, true, Void.class);
1392         });
1393 
1394 
1395         // CompareAndSet
1396         // Incorrect argument types
1397         checkNPE(() -> { // null receiver
1398             boolean r = vh.compareAndSet(null, 0, true, true);
1399         });
1400         checkCCE(() -> { // receiver reference class
1401             boolean r = vh.compareAndSet(Void.class, 0, true, true);
1402         });
1403         checkWMTE(() -> { // expected reference class
1404             boolean r = vh.compareAndSet(array, 0, Void.class, true);
1405         });
1406         checkWMTE(() -> { // actual reference class
1407             boolean r = vh.compareAndSet(array, 0, true, Void.class);
1408         });
1409         checkWMTE(() -> { // receiver primitive class
1410             boolean r = vh.compareAndSet(0, 0, true, true);
1411         });
1412         checkWMTE(() -> { // index reference class
1413             boolean r = vh.compareAndSet(array, Void.class, true, true);
1414         });
1415         // Incorrect arity
1416         checkWMTE(() -> { // 0
1417             boolean r = vh.compareAndSet();
1418         });
1419         checkWMTE(() -> { // >
1420             boolean r = vh.compareAndSet(array, 0, true, true, Void.class);
1421         });
1422 
1423 
1424         // WeakCompareAndSet
1425         // Incorrect argument types
1426         checkNPE(() -> { // null receiver
1427             boolean r = vh.weakCompareAndSet(null, 0, true, true);
1428         });
1429         checkCCE(() -> { // receiver reference class
1430             boolean r = vh.weakCompareAndSet(Void.class, 0, true, true);
1431         });
1432         checkWMTE(() -> { // expected reference class
1433             boolean r = vh.weakCompareAndSet(array, 0, Void.class, true);
1434         });
1435         checkWMTE(() -> { // actual reference class
1436             boolean r = vh.weakCompareAndSet(array, 0, true, Void.class);
1437         });
1438         checkWMTE(() -> { // receiver primitive class
1439             boolean r = vh.weakCompareAndSet(0, 0, true, true);
1440         });
1441         checkWMTE(() -> { // index reference class
1442             boolean r = vh.weakCompareAndSet(array, Void.class, true, true);
1443         });
1444         // Incorrect arity
1445         checkWMTE(() -> { // 0
1446             boolean r = vh.weakCompareAndSet();
1447         });
1448         checkWMTE(() -> { // >
1449             boolean r = vh.weakCompareAndSet(array, 0, true, true, Void.class);
1450         });
1451 
1452 
1453         // WeakCompareAndSetVolatile
1454         // Incorrect argument types
1455         checkNPE(() -> { // null receiver
1456             boolean r = vh.weakCompareAndSetVolatile(null, 0, true, true);
1457         });
1458         checkCCE(() -> { // receiver reference class
1459             boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, true, true);
1460         });
1461         checkWMTE(() -> { // expected reference class
1462             boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, true);
1463         });
1464         checkWMTE(() -> { // actual reference class
1465             boolean r = vh.weakCompareAndSetVolatile(array, 0, true, Void.class);
1466         });
1467         checkWMTE(() -> { // receiver primitive class
1468             boolean r = vh.weakCompareAndSetVolatile(0, 0, true, true);
1469         });
1470         checkWMTE(() -> { // index reference class
1471             boolean r = vh.weakCompareAndSetVolatile(array, Void.class, true, true);
1472         });
1473         // Incorrect arity
1474         checkWMTE(() -> { // 0
1475             boolean r = vh.weakCompareAndSetVolatile();
1476         });
1477         checkWMTE(() -> { // >
1478             boolean r = vh.weakCompareAndSetVolatile(array, 0, true, true, Void.class);
1479         });
1480 
1481 
1482         // WeakCompareAndSetAcquire
1483         // Incorrect argument types
1484         checkNPE(() -> { // null receiver
1485             boolean r = vh.weakCompareAndSetAcquire(null, 0, true, true);
1486         });
1487         checkCCE(() -> { // receiver reference class
1488             boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, true, true);
1489         });
1490         checkWMTE(() -> { // expected reference class
1491             boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, true);
1492         });
1493         checkWMTE(() -> { // actual reference class
1494             boolean r = vh.weakCompareAndSetAcquire(array, 0, true, Void.class);
1495         });
1496         checkWMTE(() -> { // receiver primitive class
1497             boolean r = vh.weakCompareAndSetAcquire(0, 0, true, true);
1498         });
1499         checkWMTE(() -> { // index reference class
1500             boolean r = vh.weakCompareAndSetAcquire(array, Void.class, true, true);
1501         });
1502         // Incorrect arity
1503         checkWMTE(() -> { // 0
1504             boolean r = vh.weakCompareAndSetAcquire();
1505         });
1506         checkWMTE(() -> { // >
1507             boolean r = vh.weakCompareAndSetAcquire(array, 0, true, true, Void.class);
1508         });
1509 
1510 
1511         // WeakCompareAndSetRelease
1512         // Incorrect argument types
1513         checkNPE(() -> { // null receiver
1514             boolean r = vh.weakCompareAndSetRelease(null, 0, true, true);
1515         });
1516         checkCCE(() -> { // receiver reference class
1517             boolean r = vh.weakCompareAndSetRelease(Void.class, 0, true, true);
1518         });
1519         checkWMTE(() -> { // expected reference class
1520             boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, true);
1521         });
1522         checkWMTE(() -> { // actual reference class
1523             boolean r = vh.weakCompareAndSetRelease(array, 0, true, Void.class);
1524         });
1525         checkWMTE(() -> { // receiver primitive class
1526             boolean r = vh.weakCompareAndSetRelease(0, 0, true, true);
1527         });
1528         checkWMTE(() -> { // index reference class
1529             boolean r = vh.weakCompareAndSetRelease(array, Void.class, true, true);
1530         });
1531         // Incorrect arity
1532         checkWMTE(() -> { // 0
1533             boolean r = vh.weakCompareAndSetRelease();
1534         });
1535         checkWMTE(() -> { // >
1536             boolean r = vh.weakCompareAndSetRelease(array, 0, true, true, Void.class);
1537         });
1538 
1539 
1540         // CompareAndExchangeVolatile
1541         // Incorrect argument types
1542         checkNPE(() -> { // null receiver
1543             boolean x = (boolean) vh.compareAndExchangeVolatile(null, 0, true, true);
1544         });
1545         checkCCE(() -> { // array reference class
1546             boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, 0, true, true);
1547         });
1548         checkWMTE(() -> { // expected reference class
1549             boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, Void.class, true);
1550         });
1551         checkWMTE(() -> { // actual reference class
1552             boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, true, Void.class);
1553         });
1554         checkWMTE(() -> { // array primitive class
1555             boolean x = (boolean) vh.compareAndExchangeVolatile(0, 0, true, true);
1556         });
1557         checkWMTE(() -> { // index reference class
1558             boolean x = (boolean) vh.compareAndExchangeVolatile(array, Void.class, true, true);
1559         });
1560         // Incorrect return type
1561         checkWMTE(() -> { // reference class
1562             Void r = (Void) vh.compareAndExchangeVolatile(array, 0, true, true);
1563         });
1564         checkWMTE(() -> { // primitive class
1565             int x = (int) vh.compareAndExchangeVolatile(array, 0, true, true);
1566         });
1567         // Incorrect arity
1568         checkWMTE(() -> { // 0
1569             boolean x = (boolean) vh.compareAndExchangeVolatile();
1570         });
1571         checkWMTE(() -> { // >
1572             boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, true, true, Void.class);
1573         });
1574 
1575 
1576         // CompareAndExchangeAcquire
1577         // Incorrect argument types
1578         checkNPE(() -> { // null receiver
1579             boolean x = (boolean) vh.compareAndExchangeAcquire(null, 0, true, true);
1580         });
1581         checkCCE(() -> { // array reference class
1582             boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, 0, true, true);
1583         });
1584         checkWMTE(() -> { // expected reference class
1585             boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, Void.class, true);
1586         });
1587         checkWMTE(() -> { // actual reference class
1588             boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, true, Void.class);
1589         });
1590         checkWMTE(() -> { // array primitive class
1591             boolean x = (boolean) vh.compareAndExchangeAcquire(0, 0, true, true);
1592         });
1593         checkWMTE(() -> { // index reference class
1594             boolean x = (boolean) vh.compareAndExchangeAcquire(array, Void.class, true, true);
1595         });
1596         // Incorrect return type
1597         checkWMTE(() -> { // reference class
1598             Void r = (Void) vh.compareAndExchangeAcquire(array, 0, true, true);
1599         });
1600         checkWMTE(() -> { // primitive class
1601             int x = (int) vh.compareAndExchangeAcquire(array, 0, true, true);
1602         });
1603         // Incorrect arity
1604         checkWMTE(() -> { // 0
1605             boolean x = (boolean) vh.compareAndExchangeAcquire();
1606         });
1607         checkWMTE(() -> { // >
1608             boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, true, true, Void.class);
1609         });
1610 
1611 
1612         // CompareAndExchangeRelease
1613         // Incorrect argument types
1614         checkNPE(() -> { // null receiver
1615             boolean x = (boolean) vh.compareAndExchangeRelease(null, 0, true, true);
1616         });
1617         checkCCE(() -> { // array reference class
1618             boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, 0, true, true);
1619         });
1620         checkWMTE(() -> { // expected reference class
1621             boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, Void.class, true);
1622         });
1623         checkWMTE(() -> { // actual reference class
1624             boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, true, Void.class);
1625         });
1626         checkWMTE(() -> { // array primitive class
1627             boolean x = (boolean) vh.compareAndExchangeRelease(0, 0, true, true);
1628         });
1629         checkWMTE(() -> { // index reference class
1630             boolean x = (boolean) vh.compareAndExchangeRelease(array, Void.class, true, true);
1631         });
1632         // Incorrect return type
1633         checkWMTE(() -> { // reference class
1634             Void r = (Void) vh.compareAndExchangeRelease(array, 0, true, true);
1635         });
1636         checkWMTE(() -> { // primitive class
1637             int x = (int) vh.compareAndExchangeRelease(array, 0, true, true);
1638         });
1639         // Incorrect arity
1640         checkWMTE(() -> { // 0
1641             boolean x = (boolean) vh.compareAndExchangeRelease();
1642         });
1643         checkWMTE(() -> { // >
1644             boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, true, true, Void.class);
1645         });
1646 
1647 
1648         // GetAndSet
1649         // Incorrect argument types
1650         checkNPE(() -> { // null array
1651             boolean x = (boolean) vh.getAndSet(null, 0, true);
1652         });
1653         checkCCE(() -> { // array reference class
1654             boolean x = (boolean) vh.getAndSet(Void.class, 0, true);
1655         });
1656         checkWMTE(() -> { // value reference class
1657             boolean x = (boolean) vh.getAndSet(array, 0, Void.class);
1658         });
1659         checkWMTE(() -> { // reciarrayever primitive class
1660             boolean x = (boolean) vh.getAndSet(0, 0, true);
1661         });
1662         checkWMTE(() -> { // index reference class
1663             boolean x = (boolean) vh.getAndSet(array, Void.class, true);
1664         });
1665         // Incorrect return type
1666         checkWMTE(() -> { // reference class
1667             Void r = (Void) vh.getAndSet(array, 0, true);
1668         });
1669         checkWMTE(() -> { // primitive class
1670             int x = (int) vh.getAndSet(array, 0, true);
1671         });
1672         // Incorrect arity
1673         checkWMTE(() -> { // 0
1674             boolean x = (boolean) vh.getAndSet();
1675         });
1676         checkWMTE(() -> { // >
1677             boolean x = (boolean) vh.getAndSet(array, 0, true, Void.class);
1678         });
1679 
1680     }
1681 
1682     static void testArrayWrongMethodType(Handles hs) throws Throwable {
1683         boolean[] array = new boolean[10];
1684         Arrays.fill(array, true);
1685 
1686         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
1687             // Incorrect argument types
1688             checkNPE(() -> { // null array
1689                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)).
1690                     invoke(null, 0);
1691             });
1692             checkCCE(() -> { // array reference class
1693                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
1694                     invoke(Void.class, 0);
1695             });
1696             checkWMTE(() -> { // array primitive class
1697                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
1698                     invoke(0, 0);


1733             });
1734             checkWMTE(() -> { // value reference class
1735                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
1736                     invoke(array, 0, Void.class);
1737             });
1738             checkWMTE(() -> { // receiver primitive class
1739                 hs.get(am, methodType(void.class, int.class, int.class, boolean.class)).
1740                     invoke(0, 0, true);
1741             });
1742             checkWMTE(() -> { // index reference class
1743                 hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)).
1744                     invoke(array, Void.class, true);
1745             });
1746             // Incorrect arity
1747             checkWMTE(() -> { // 0
1748                 hs.get(am, methodType(void.class)).
1749                     invoke();
1750             });
1751             checkWMTE(() -> { // >
1752                 hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
1753                     invoke(array, 0, true, Void.class);
1754             });
1755         }
1756         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
1757             // Incorrect argument types
1758             checkNPE(() -> { // null receiver
1759                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, boolean.class, boolean.class)).
1760                     invoke(null, 0, true, true);
1761             });
1762             checkCCE(() -> { // receiver reference class
1763                 boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class, boolean.class)).
1764                     invoke(Void.class, 0, true, true);
1765             });
1766             checkWMTE(() -> { // expected reference class
1767                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class, boolean.class)).
1768                     invoke(array, 0, Void.class, true);
1769             });
1770             checkWMTE(() -> { // actual reference class
1771                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
1772                     invoke(array, 0, true, Void.class);
1773             });
1774             checkWMTE(() -> { // receiver primitive class
1775                 boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class, boolean.class)).
1776                     invoke(0, 0, true, true);
1777             });
1778             checkWMTE(() -> { // index reference class
1779                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class, boolean.class)).
1780                     invoke(array, Void.class, true, true);
1781             });
1782             // Incorrect arity
1783             checkWMTE(() -> { // 0
1784                 boolean r = (boolean) hs.get(am, methodType(boolean.class)).
1785                     invoke();
1786             });
1787             checkWMTE(() -> { // >
1788                 boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, boolean.class, Class.class)).
1789                     invoke(array, 0, true, true, Void.class);
1790             });
1791         }
1792 
1793         for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
1794             // Incorrect argument types
1795             checkNPE(() -> { // null receiver
1796                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, boolean.class, boolean.class)).
1797                     invoke(null, 0, true, true);
1798             });
1799             checkCCE(() -> { // array reference class
1800                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class, boolean.class)).
1801                     invoke(Void.class, 0, true, true);
1802             });
1803             checkWMTE(() -> { // expected reference class
1804                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class, boolean.class)).
1805                     invoke(array, 0, Void.class, true);
1806             });
1807             checkWMTE(() -> { // actual reference class
1808                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
1809                     invoke(array, 0, true, Void.class);
1810             });
1811             checkWMTE(() -> { // array primitive class
1812                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class, boolean.class)).
1813                     invoke(0, 0, true, true);
1814             });
1815             checkWMTE(() -> { // index reference class
1816                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class, boolean.class)).
1817                     invoke(array, Void.class, true, true);
1818             });
1819             // Incorrect return type
1820             checkWMTE(() -> { // reference class
1821                 Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class, boolean.class)).
1822                     invoke(array, 0, true, true);
1823             });
1824             checkWMTE(() -> { // primitive class
1825                 int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class, boolean.class)).
1826                     invoke(array, 0, true, true);
1827             });
1828             // Incorrect arity
1829             checkWMTE(() -> { // 0
1830                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
1831                     invoke();
1832             });
1833             checkWMTE(() -> { // >
1834                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, boolean.class, Class.class)).
1835                     invoke(array, 0, true, true, Void.class);
1836             });
1837         }
1838 
1839         for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
1840             // Incorrect argument types
1841             checkNPE(() -> { // null array
1842                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, boolean.class)).
1843                     invoke(null, 0, true);
1844             });
1845             checkCCE(() -> { // array reference class
1846                 boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class)).
1847                     invoke(Void.class, 0, true);
1848             });
1849             checkWMTE(() -> { // value reference class
1850                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)).
1851                     invoke(array, 0, Void.class);
1852             });
1853             checkWMTE(() -> { // array primitive class
1854                 boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class)).
1855                     invoke(0, 0, true);
1856             });
1857             checkWMTE(() -> { // index reference class
1858                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class)).
1859                     invoke(array, Void.class, true);
1860             });
1861             // Incorrect return type
1862             checkWMTE(() -> { // reference class
1863                 Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class)).
1864                     invoke(array, 0, true);
1865             });
1866             checkWMTE(() -> { // primitive class
1867                 int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class)).
1868                     invoke(array, 0, true);
1869             });
1870             // Incorrect arity
1871             checkWMTE(() -> { // 0
1872                 boolean x = (boolean) hs.get(am, methodType(boolean.class)).
1873                     invoke();
1874             });
1875             checkWMTE(() -> { // >
1876                 boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
1877                     invoke(array, 0, true, Void.class);
1878             });
1879         }
1880 
1881     }
1882 }
1883 
< prev index next >