1 2 // Run with -XX:+UseNewAcmp -XX:ValueBasedClasses="MyValue" 3 4 import java.lang.invoke.*; 5 import java.lang.reflect.Method; 6 import java.util.regex.Pattern; 7 import java.util.regex.Matcher; 8 9 interface MyInterface { 10 11 } 12 13 class MyValue implements MyInterface { 14 int x; 15 } 16 17 class MyObject implements MyInterface { 18 int x; 19 } 20 21 public class Test { 22 23 public Object f1 = null; 24 25 public void myMethod() { 26 27 } 28 29 /* 30 public boolean testEq01_1(Object u1, Object u2) { 31 if (u1 == null) { 32 return false; 33 } 34 if (u2 == u1) { 35 return true; 36 } 37 //System.gc(); 38 myMethod(); 39 if (f1 == u1) { 40 return true; 41 } 42 return false; 43 } 44 */ 45 46 public boolean testEq01_1(Object u1, Object u2) { 47 return get(u1) == u2; // new acmp 48 } 49 50 public boolean testEq01_2(Object u1, Object u2) { 51 return u1 == get(u2); // new acmp 52 } 53 54 public boolean testEq01_3(Object u1, Object u2) { 55 return get(u1) == get(u2); // new acmp 56 } 57 58 public boolean testEq01_4(Object u1, Object u2) { 59 return getNotNull(u1) == u2; // new acmp without null check 60 } 61 62 public boolean testEq01_5(Object u1, Object u2) { 63 return u1 == getNotNull(u2); // new acmp without null check 64 } 65 66 public boolean testEq01_6(Object u1, Object u2) { 67 return getNotNull(u1) == getNotNull(u2); // new acmp without null check 68 } 69 70 public boolean testEq02_1(MyValue v1, MyValue v2) { 71 return get(v1) == v2; // only true if both null 72 } 73 74 public boolean testEq02_2(MyValue v1, MyValue v2) { 75 return v1 == get(v2); // only true if both null 76 } 77 78 public boolean testEq02_3(MyValue v1, MyValue v2) { 79 return get(v1) == get(v2); // only true if both null 80 } 81 82 public boolean testEq03_1(MyValue v, Object u) { 83 return get(v) == u; // only true if both null 84 } 85 86 public boolean testEq03_2(MyValue v, Object u) { 87 return v == get(u); // only true if both null 88 } 89 90 public boolean testEq03_3(MyValue v, Object u) { 91 return get(v) == get(u); // only true if both null 92 } 93 94 public boolean testEq04_1(Object u, MyValue v) { 95 return get(u) == v; // only true if both null 96 } 97 98 public boolean testEq04_2(Object u, MyValue v) { 99 return u == get(v); // only true if both null 100 } 101 102 public boolean testEq04_3(Object u, MyValue v) { 103 return get(u) == get(v); // only true if both null 104 } 105 106 public boolean testEq05_1(MyObject o, MyValue v) { 107 return get(o) == v; // only true if both null 108 } 109 110 public boolean testEq05_2(MyObject o, MyValue v) { 111 return o == get(v); // only true if both null 112 } 113 114 public boolean testEq05_3(MyObject o, MyValue v) { 115 return get(o) == get(v); // only true if both null 116 } 117 118 public boolean testEq06_1(MyValue v, MyObject o) { 119 return get(v) == o; // only true if both null 120 } 121 122 public boolean testEq06_2(MyValue v, MyObject o) { 123 return v == get(o); // only true if both null 124 } 125 126 public boolean testEq06_3(MyValue v, MyObject o) { 127 return get(v) == get(o); // only true if both null 128 } 129 130 public boolean testEq07_1(MyValue v1, MyValue v2) { 131 return getNotNull(v1) == v2; // false 132 } 133 134 public boolean testEq07_2(MyValue v1, MyValue v2) { 135 return v1 == getNotNull(v2); // false 136 } 137 138 public boolean testEq07_3(MyValue v1, MyValue v2) { 139 return getNotNull(v1) == getNotNull(v2); // false 140 } 141 142 public boolean testEq08_1(MyValue v, Object u) { 143 return getNotNull(v) == u; // false 144 } 145 146 public boolean testEq08_2(MyValue v, Object u) { 147 return v == getNotNull(u); // false 148 } 149 150 public boolean testEq08_3(MyValue v, Object u) { 151 return getNotNull(v) == getNotNull(u); // false 152 } 153 154 public boolean testEq09_1(Object u, MyValue v) { 155 return getNotNull(u) == v; // false 156 } 157 158 public boolean testEq09_2(Object u, MyValue v) { 159 return u == getNotNull(v); // false 160 } 161 162 public boolean testEq09_3(Object u, MyValue v) { 163 return getNotNull(u) == getNotNull(v); // false 164 } 165 166 public boolean testEq10_1(MyObject o, MyValue v) { 167 return getNotNull(o) == v; // false 168 } 169 170 public boolean testEq10_2(MyObject o, MyValue v) { 171 return o == getNotNull(v); // false 172 } 173 174 public boolean testEq10_3(MyObject o, MyValue v) { 175 return getNotNull(o) == getNotNull(v); // false 176 } 177 178 public boolean testEq11_1(MyValue v, MyObject o) { 179 return getNotNull(v) == o; // false 180 } 181 182 public boolean testEq11_2(MyValue v, MyObject o) { 183 return v == getNotNull(o); // false 184 } 185 186 public boolean testEq11_3(MyValue v, MyObject o) { 187 return getNotNull(v) == getNotNull(o); // false 188 } 189 190 public boolean testEq12_1(MyObject o1, MyObject o2) { 191 return get(o1) == o2; // old acmp 192 } 193 194 public boolean testEq12_2(MyObject o1, MyObject o2) { 195 return o1 == get(o2); // old acmp 196 } 197 198 public boolean testEq12_3(MyObject o1, MyObject o2) { 199 return get(o1) == get(o2); // old acmp 200 } 201 202 public boolean testEq13_1(Object u, MyObject o) { 203 return get(u) == o; // old acmp 204 } 205 206 public boolean testEq13_2(Object u, MyObject o) { 207 return u == get(o); // old acmp 208 } 209 210 public boolean testEq13_3(Object u, MyObject o) { 211 return get(u) == get(o); // old acmp 212 } 213 214 public boolean testEq14_1(MyObject o, Object u) { 215 return get(o) == u; // old acmp 216 } 217 218 public boolean testEq14_2(MyObject o, Object u) { 219 return o == get(u); // old acmp 220 } 221 222 public boolean testEq14_3(MyObject o, Object u) { 223 return get(o) == get(u); // old acmp 224 } 225 226 public boolean testEq15_1(Object[] a, Object u) { 227 return get(a) == u; // old acmp 228 } 229 230 public boolean testEq15_2(Object[] a, Object u) { 231 return a == get(u); // old acmp 232 } 233 234 public boolean testEq15_3(Object[] a, Object u) { 235 return get(a) == get(u); // old acmp 236 } 237 238 public boolean testEq16_1(Object u, Object[] a) { 239 return get(u) == a; // old acmp 240 } 241 242 public boolean testEq16_2(Object u, Object[] a) { 243 return u == get(a); // old acmp 244 } 245 246 public boolean testEq16_3(Object u, Object[] a) { 247 return get(u) == get(a); // old acmp 248 } 249 250 public boolean testEq17_1(Object[] a, MyValue v) { 251 return get(a) == v; // only true if both null 252 } 253 254 public boolean testEq17_2(Object[] a, MyValue v) { 255 return a == get(v); // only true if both null 256 } 257 258 public boolean testEq17_3(Object[] a, MyValue v) { 259 return get(a) == get(v); // only true if both null 260 } 261 262 public boolean testEq18_1(MyValue v, Object[] a) { 263 return get(v) == a; // only true if both null 264 } 265 266 public boolean testEq18_2(MyValue v, Object[] a) { 267 return v == get(a); // only true if both null 268 } 269 270 public boolean testEq18_3(MyValue v, Object[] a) { 271 return get(v) == get(a); // only true if both null 272 } 273 274 public boolean testEq19_1(Object[] a, MyValue v) { 275 return getNotNull(a) == v; // false 276 } 277 278 public boolean testEq19_2(Object[] a, MyValue v) { 279 return a == getNotNull(v); // false 280 } 281 282 public boolean testEq19_3(Object[] a, MyValue v) { 283 return getNotNull(a) == getNotNull(v); // false 284 } 285 286 public boolean testEq20_1(MyValue v, Object[] a) { 287 return getNotNull(v) == a; // false 288 } 289 290 public boolean testEq20_2(MyValue v, Object[] a) { 291 return v == getNotNull(a); // false 292 } 293 294 public boolean testEq20_3(MyValue v, Object[] a) { 295 return getNotNull(v) == getNotNull(a); // false 296 } 297 298 public boolean testEq21_1(MyInterface u1, MyInterface u2) { 299 return get(u1) == u2; // new acmp 300 } 301 302 public boolean testEq21_2(MyInterface u1, MyInterface u2) { 303 return u1 == get(u2); // new acmp 304 } 305 306 public boolean testEq21_3(MyInterface u1, MyInterface u2) { 307 return get(u1) == get(u2); // new acmp 308 } 309 310 public boolean testEq21_4(MyInterface u1, MyInterface u2) { 311 return getNotNull(u1) == u2; // new acmp without null check 312 } 313 314 public boolean testEq21_5(MyInterface u1, MyInterface u2) { 315 return u1 == getNotNull(u2); // new acmp without null check 316 } 317 318 public boolean testEq21_6(MyInterface u1, MyInterface u2) { 319 return getNotNull(u1) == getNotNull(u2); // new acmp without null check 320 } 321 322 public boolean testEq22_1(MyValue v, MyInterface u) { 323 return get(v) == u; // only true if both null 324 } 325 326 public boolean testEq22_2(MyValue v, MyInterface u) { 327 return v == get(u); // only true if both null 328 } 329 330 public boolean testEq22_3(MyValue v, MyInterface u) { 331 return get(v) == get(u); // only true if both null 332 } 333 334 public boolean testEq23_1(MyInterface u, MyValue v) { 335 return get(u) == v; // only true if both null 336 } 337 338 public boolean testEq23_2(MyInterface u, MyValue v) { 339 return u == get(v); // only true if both null 340 } 341 342 public boolean testEq23_3(MyInterface u, MyValue v) { 343 return get(u) == get(v); // only true if both null 344 } 345 346 public boolean testEq24_1(MyValue v, MyInterface u) { 347 return getNotNull(v) == u; // false 348 } 349 350 public boolean testEq24_2(MyValue v, MyInterface u) { 351 return v == getNotNull(u); // false 352 } 353 354 public boolean testEq24_3(MyValue v, MyInterface u) { 355 return getNotNull(v) == getNotNull(u); // false 356 } 357 358 public boolean testEq25_1(MyInterface u, MyValue v) { 359 return getNotNull(u) == v; // false 360 } 361 362 public boolean testEq25_2(MyInterface u, MyValue v) { 363 return u == getNotNull(v); // false 364 } 365 366 public boolean testEq25_3(MyInterface u, MyValue v) { 367 return getNotNull(u) == getNotNull(v); // false 368 } 369 370 public boolean testEq26_1(MyInterface u, MyObject o) { 371 return get(u) == o; // old acmp 372 } 373 374 public boolean testEq26_2(MyInterface u, MyObject o) { 375 return u == get(o); // old acmp 376 } 377 378 public boolean testEq26_3(MyInterface u, MyObject o) { 379 return get(u) == get(o); // old acmp 380 } 381 382 public boolean testEq27_1(MyObject o, MyInterface u) { 383 return get(o) == u; // old acmp 384 } 385 386 public boolean testEq27_2(MyObject o, MyInterface u) { 387 return o == get(u); // old acmp 388 } 389 390 public boolean testEq27_3(MyObject o, MyInterface u) { 391 return get(o) == get(u); // old acmp 392 } 393 394 public boolean testEq28_1(MyInterface[] a, MyInterface u) { 395 return get(a) == u; // old acmp 396 } 397 398 public boolean testEq28_2(MyInterface[] a, MyInterface u) { 399 return a == get(u); // old acmp 400 } 401 402 public boolean testEq28_3(MyInterface[] a, MyInterface u) { 403 return get(a) == get(u); // old acmp 404 } 405 406 public boolean testEq29_1(MyInterface u, MyInterface[] a) { 407 return get(u) == a; // old acmp 408 } 409 410 public boolean testEq29_2(MyInterface u, MyInterface[] a) { 411 return u == get(a); // old acmp 412 } 413 414 public boolean testEq29_3(MyInterface u, MyInterface[] a) { 415 return get(u) == get(a); // old acmp 416 } 417 418 public boolean testEq30_1(MyInterface[] a, MyValue v) { 419 return get(a) == v; // only true if both null 420 } 421 422 public boolean testEq30_2(MyInterface[] a, MyValue v) { 423 return a == get(v); // only true if both null 424 } 425 426 public boolean testEq30_3(MyInterface[] a, MyValue v) { 427 return get(a) == get(v); // only true if both null 428 } 429 430 public boolean testEq31_1(MyValue v, MyInterface[] a) { 431 return get(v) == a; // only true if both null 432 } 433 434 public boolean testEq31_2(MyValue v, MyInterface[] a) { 435 return v == get(a); // only true if both null 436 } 437 438 public boolean testEq31_3(MyValue v, MyInterface[] a) { 439 return get(v) == get(a); // only true if both null 440 } 441 442 public boolean testEq32_1(MyInterface[] a, MyValue v) { 443 return getNotNull(a) == v; // false 444 } 445 446 public boolean testEq32_2(MyInterface[] a, MyValue v) { 447 return a == getNotNull(v); // false 448 } 449 450 public boolean testEq32_3(MyInterface[] a, MyValue v) { 451 return getNotNull(a) == getNotNull(v); // false 452 } 453 454 public boolean testEq33_1(MyValue v, MyInterface[] a) { 455 return getNotNull(v) == a; // false 456 } 457 458 public boolean testEq33_2(MyValue v, MyInterface[] a) { 459 return v == getNotNull(a); // false 460 } 461 462 public boolean testEq33_3(MyValue v, MyInterface[] a) { 463 return getNotNull(v) == getNotNull(a); // false 464 } 465 466 467 // Null tests 468 469 public boolean testNull01_1(MyValue v) { 470 return v == null; // old acmp 471 } 472 473 public boolean testNull01_2(MyValue v) { 474 return get(v) == null; // old acmp 475 } 476 477 public boolean testNull01_3(MyValue v) { 478 return v == get((Object)null); // old acmp 479 } 480 481 public boolean testNull01_4(MyValue v) { 482 return get(v) == get((Object)null); // old acmp 483 } 484 485 public boolean testNull02_1(MyValue v) { 486 return null == v; // old acmp 487 } 488 489 public boolean testNull02_2(MyValue v) { 490 return get((Object)null) == v; // old acmp 491 } 492 493 public boolean testNull02_3(MyValue v) { 494 return null == get(v); // old acmp 495 } 496 497 public boolean testNull02_4(MyValue v) { 498 return get((Object)null) == get(v); // old acmp 499 } 500 501 public boolean testNull03_1(Object u) { 502 return u == null; // old acmp 503 } 504 505 public boolean testNull03_2(Object u) { 506 return get(u) == null; // old acmp 507 } 508 509 public boolean testNull03_3(Object u) { 510 return u == get((Object)null); // old acmp 511 } 512 513 public boolean testNull03_4(Object u) { 514 return get(u) == get((Object)null); // old acmp 515 } 516 517 public boolean testNull04_1(Object u) { 518 return null == u; // old acmp 519 } 520 521 public boolean testNull04_2(Object u) { 522 return get((Object)null) == u; // old acmp 523 } 524 525 public boolean testNull04_3(Object u) { 526 return null == get(u); // old acmp 527 } 528 529 public boolean testNull04_4(Object u) { 530 return get((Object)null) == get(u); // old acmp 531 } 532 533 public boolean testNull05_1(MyObject o) { 534 return o == null; // old acmp 535 } 536 537 public boolean testNull05_2(MyObject o) { 538 return get(o) == null; // old acmp 539 } 540 541 public boolean testNull05_3(MyObject o) { 542 return o == get((Object)null); // old acmp 543 } 544 545 public boolean testNull05_4(MyObject o) { 546 return get(o) == get((Object)null); // old acmp 547 } 548 549 public boolean testNull06_1(MyObject o) { 550 return null == o; // old acmp 551 } 552 553 public boolean testNull06_2(MyObject o) { 554 return get((Object)null) == o; // old acmp 555 } 556 557 public boolean testNull06_3(MyObject o) { 558 return null == get(o); // old acmp 559 } 560 561 public boolean testNull06_4(MyObject o) { 562 return get((Object)null) == get(o); // old acmp 563 } 564 565 public boolean testNull07_1(MyInterface u) { 566 return u == null; // old acmp 567 } 568 569 public boolean testNull07_2(MyInterface u) { 570 return get(u) == null; // old acmp 571 } 572 573 public boolean testNull07_3(MyInterface u) { 574 return u == get((Object)null); // old acmp 575 } 576 577 public boolean testNull07_4(MyInterface u) { 578 return get(u) == get((Object)null); // old acmp 579 } 580 581 public boolean testNull08_1(MyInterface u) { 582 return null == u; // old acmp 583 } 584 585 public boolean testNull08_2(MyInterface u) { 586 return get((Object)null) == u; // old acmp 587 } 588 589 public boolean testNull08_3(MyInterface u) { 590 return null == get(u); // old acmp 591 } 592 593 public boolean testNull08_4(MyInterface u) { 594 return get((Object)null) == get(u); // old acmp 595 } 596 597 // Same tests as above but negated 598 599 public boolean testNotEq01_1(Object u1, Object u2) { 600 return get(u1) != u2; // new acmp 601 } 602 603 public boolean testNotEq01_2(Object u1, Object u2) { 604 return u1 != get(u2); // new acmp 605 } 606 607 public boolean testNotEq01_3(Object u1, Object u2) { 608 return get(u1) != get(u2); // new acmp 609 } 610 611 public boolean testNotEq01_4(Object u1, Object u2) { 612 return getNotNull(u1) != u2; // new acmp without null check 613 } 614 615 public boolean testNotEq01_5(Object u1, Object u2) { 616 return u1 != getNotNull(u2); // new acmp without null check 617 } 618 619 public boolean testNotEq01_6(Object u1, Object u2) { 620 return getNotNull(u1) != getNotNull(u2); // new acmp without null check 621 } 622 623 public boolean testNotEq02_1(MyValue v1, MyValue v2) { 624 return get(v1) != v2; // only false if both null 625 } 626 627 public boolean testNotEq02_2(MyValue v1, MyValue v2) { 628 return v1 != get(v2); // only false if both null 629 } 630 631 public boolean testNotEq02_3(MyValue v1, MyValue v2) { 632 return get(v1) != get(v2); // only false if both null 633 } 634 635 public boolean testNotEq03_1(MyValue v, Object u) { 636 return get(v) != u; // only false if both null 637 } 638 639 public boolean testNotEq03_2(MyValue v, Object u) { 640 return v != get(u); // only false if both null 641 } 642 643 public boolean testNotEq03_3(MyValue v, Object u) { 644 return get(v) != get(u); // only false if both null 645 } 646 647 public boolean testNotEq04_1(Object u, MyValue v) { 648 return get(u) != v; // only false if both null 649 } 650 651 public boolean testNotEq04_2(Object u, MyValue v) { 652 return u != get(v); // only false if both null 653 } 654 655 public boolean testNotEq04_3(Object u, MyValue v) { 656 return get(u) != get(v); // only false if both null 657 } 658 659 public boolean testNotEq05_1(MyObject o, MyValue v) { 660 return get(o) != v; // only false if both null 661 } 662 663 public boolean testNotEq05_2(MyObject o, MyValue v) { 664 return o != get(v); // only false if both null 665 } 666 667 public boolean testNotEq05_3(MyObject o, MyValue v) { 668 return get(o) != get(v); // only false if both null 669 } 670 671 public boolean testNotEq06_1(MyValue v, MyObject o) { 672 return get(v) != o; // only false if both null 673 } 674 675 public boolean testNotEq06_2(MyValue v, MyObject o) { 676 return v != get(o); // only false if both null 677 } 678 679 public boolean testNotEq06_3(MyValue v, MyObject o) { 680 return get(v) != get(o); // only false if both null 681 } 682 683 public boolean testNotEq07_1(MyValue v1, MyValue v2) { 684 return getNotNull(v1) != v2; // true 685 } 686 687 public boolean testNotEq07_2(MyValue v1, MyValue v2) { 688 return v1 != getNotNull(v2); // true 689 } 690 691 public boolean testNotEq07_3(MyValue v1, MyValue v2) { 692 return getNotNull(v1) != getNotNull(v2); // true 693 } 694 695 public boolean testNotEq08_1(MyValue v, Object u) { 696 return getNotNull(v) != u; // true 697 } 698 699 public boolean testNotEq08_2(MyValue v, Object u) { 700 return v != getNotNull(u); // true 701 } 702 703 public boolean testNotEq08_3(MyValue v, Object u) { 704 return getNotNull(v) != getNotNull(u); // true 705 } 706 707 public boolean testNotEq09_1(Object u, MyValue v) { 708 return getNotNull(u) != v; // true 709 } 710 711 public boolean testNotEq09_2(Object u, MyValue v) { 712 return u != getNotNull(v); // true 713 } 714 715 public boolean testNotEq09_3(Object u, MyValue v) { 716 return getNotNull(u) != getNotNull(v); // true 717 } 718 719 public boolean testNotEq10_1(MyObject o, MyValue v) { 720 return getNotNull(o) != v; // true 721 } 722 723 public boolean testNotEq10_2(MyObject o, MyValue v) { 724 return o != getNotNull(v); // true 725 } 726 727 public boolean testNotEq10_3(MyObject o, MyValue v) { 728 return getNotNull(o) != getNotNull(v); // true 729 } 730 731 public boolean testNotEq11_1(MyValue v, MyObject o) { 732 return getNotNull(v) != o; // true 733 } 734 735 public boolean testNotEq11_2(MyValue v, MyObject o) { 736 return v != getNotNull(o); // true 737 } 738 739 public boolean testNotEq11_3(MyValue v, MyObject o) { 740 return getNotNull(v) != getNotNull(o); // true 741 } 742 743 public boolean testNotEq12_1(MyObject o1, MyObject o2) { 744 return get(o1) != o2; // old acmp 745 } 746 747 public boolean testNotEq12_2(MyObject o1, MyObject o2) { 748 return o1 != get(o2); // old acmp 749 } 750 751 public boolean testNotEq12_3(MyObject o1, MyObject o2) { 752 return get(o1) != get(o2); // old acmp 753 } 754 755 public boolean testNotEq13_1(Object u, MyObject o) { 756 return get(u) != o; // old acmp 757 } 758 759 public boolean testNotEq13_2(Object u, MyObject o) { 760 return u != get(o); // old acmp 761 } 762 763 public boolean testNotEq13_3(Object u, MyObject o) { 764 return get(u) != get(o); // old acmp 765 } 766 767 public boolean testNotEq14_1(MyObject o, Object u) { 768 return get(o) != u; // old acmp 769 } 770 771 public boolean testNotEq14_2(MyObject o, Object u) { 772 return o != get(u); // old acmp 773 } 774 775 public boolean testNotEq14_3(MyObject o, Object u) { 776 return get(o) != get(u); // old acmp 777 } 778 779 public boolean testNotEq15_1(Object[] a, Object u) { 780 return get(a) != u; // old acmp 781 } 782 783 public boolean testNotEq15_2(Object[] a, Object u) { 784 return a != get(u); // old acmp 785 } 786 787 public boolean testNotEq15_3(Object[] a, Object u) { 788 return get(a) != get(u); // old acmp 789 } 790 791 public boolean testNotEq16_1(Object u, Object[] a) { 792 return get(u) != a; // old acmp 793 } 794 795 public boolean testNotEq16_2(Object u, Object[] a) { 796 return u != get(a); // old acmp 797 } 798 799 public boolean testNotEq16_3(Object u, Object[] a) { 800 return get(u) != get(a); // old acmp 801 } 802 803 public boolean testNotEq17_1(Object[] a, MyValue v) { 804 return get(a) != v; // only false if both null 805 } 806 807 public boolean testNotEq17_2(Object[] a, MyValue v) { 808 return a != get(v); // only false if both null 809 } 810 811 public boolean testNotEq17_3(Object[] a, MyValue v) { 812 return get(a) != get(v); // only false if both null 813 } 814 815 public boolean testNotEq18_1(MyValue v, Object[] a) { 816 return get(v) != a; // only false if both null 817 } 818 819 public boolean testNotEq18_2(MyValue v, Object[] a) { 820 return v != get(a); // only false if both null 821 } 822 823 public boolean testNotEq18_3(MyValue v, Object[] a) { 824 return get(v) != get(a); // only false if both null 825 } 826 827 public boolean testNotEq19_1(Object[] a, MyValue v) { 828 return getNotNull(a) != v; // true 829 } 830 831 public boolean testNotEq19_2(Object[] a, MyValue v) { 832 return a != getNotNull(v); // true 833 } 834 835 public boolean testNotEq19_3(Object[] a, MyValue v) { 836 return getNotNull(a) != getNotNull(v); // true 837 } 838 839 public boolean testNotEq20_1(MyValue v, Object[] a) { 840 return getNotNull(v) != a; // true 841 } 842 843 public boolean testNotEq20_2(MyValue v, Object[] a) { 844 return v != getNotNull(a); // true 845 } 846 847 public boolean testNotEq20_3(MyValue v, Object[] a) { 848 return getNotNull(v) != getNotNull(a); // true 849 } 850 851 public boolean testNotEq21_1(MyInterface u1, MyInterface u2) { 852 return get(u1) != u2; // new acmp 853 } 854 855 public boolean testNotEq21_2(MyInterface u1, MyInterface u2) { 856 return u1 != get(u2); // new acmp 857 } 858 859 public boolean testNotEq21_3(MyInterface u1, MyInterface u2) { 860 return get(u1) != get(u2); // new acmp 861 } 862 863 public boolean testNotEq21_4(MyInterface u1, MyInterface u2) { 864 return getNotNull(u1) != u2; // new acmp without null check 865 } 866 867 public boolean testNotEq21_5(MyInterface u1, MyInterface u2) { 868 return u1 != getNotNull(u2); // new acmp without null check 869 } 870 871 public boolean testNotEq21_6(MyInterface u1, MyInterface u2) { 872 return getNotNull(u1) != getNotNull(u2); // new acmp without null check 873 } 874 875 public boolean testNotEq22_1(MyValue v, MyInterface u) { 876 return get(v) != u; // only false if both null 877 } 878 879 public boolean testNotEq22_2(MyValue v, MyInterface u) { 880 return v != get(u); // only false if both null 881 } 882 883 public boolean testNotEq22_3(MyValue v, MyInterface u) { 884 return get(v) != get(u); // only false if both null 885 } 886 887 public boolean testNotEq23_1(MyInterface u, MyValue v) { 888 return get(u) != v; // only false if both null 889 } 890 891 public boolean testNotEq23_2(MyInterface u, MyValue v) { 892 return u != get(v); // only false if both null 893 } 894 895 public boolean testNotEq23_3(MyInterface u, MyValue v) { 896 return get(u) != get(v); // only false if both null 897 } 898 899 public boolean testNotEq24_1(MyValue v, MyInterface u) { 900 return getNotNull(v) != u; // true 901 } 902 903 public boolean testNotEq24_2(MyValue v, MyInterface u) { 904 return v != getNotNull(u); // true 905 } 906 907 public boolean testNotEq24_3(MyValue v, MyInterface u) { 908 return getNotNull(v) != getNotNull(u); // true 909 } 910 911 public boolean testNotEq25_1(MyInterface u, MyValue v) { 912 return getNotNull(u) != v; // true 913 } 914 915 public boolean testNotEq25_2(MyInterface u, MyValue v) { 916 return u != getNotNull(v); // true 917 } 918 919 public boolean testNotEq25_3(MyInterface u, MyValue v) { 920 return getNotNull(u) != getNotNull(v); // true 921 } 922 923 public boolean testNotEq26_1(MyInterface u, MyObject o) { 924 return get(u) != o; // old acmp 925 } 926 927 public boolean testNotEq26_2(MyInterface u, MyObject o) { 928 return u != get(o); // old acmp 929 } 930 931 public boolean testNotEq26_3(MyInterface u, MyObject o) { 932 return get(u) != get(o); // old acmp 933 } 934 935 public boolean testNotEq27_1(MyObject o, MyInterface u) { 936 return get(o) != u; // old acmp 937 } 938 939 public boolean testNotEq27_2(MyObject o, MyInterface u) { 940 return o != get(u); // old acmp 941 } 942 943 public boolean testNotEq27_3(MyObject o, MyInterface u) { 944 return get(o) != get(u); // old acmp 945 } 946 947 public boolean testNotEq28_1(MyInterface[] a, MyInterface u) { 948 return get(a) != u; // old acmp 949 } 950 951 public boolean testNotEq28_2(MyInterface[] a, MyInterface u) { 952 return a != get(u); // old acmp 953 } 954 955 public boolean testNotEq28_3(MyInterface[] a, MyInterface u) { 956 return get(a) != get(u); // old acmp 957 } 958 959 public boolean testNotEq29_1(MyInterface u, MyInterface[] a) { 960 return get(u) != a; // old acmp 961 } 962 963 public boolean testNotEq29_2(MyInterface u, MyInterface[] a) { 964 return u != get(a); // old acmp 965 } 966 967 public boolean testNotEq29_3(MyInterface u, MyInterface[] a) { 968 return get(u) != get(a); // old acmp 969 } 970 971 public boolean testNotEq30_1(MyInterface[] a, MyValue v) { 972 return get(a) != v; // only false if both null 973 } 974 975 public boolean testNotEq30_2(MyInterface[] a, MyValue v) { 976 return a != get(v); // only false if both null 977 } 978 979 public boolean testNotEq30_3(MyInterface[] a, MyValue v) { 980 return get(a) != get(v); // only false if both null 981 } 982 983 public boolean testNotEq31_1(MyValue v, MyInterface[] a) { 984 return get(v) != a; // only false if both null 985 } 986 987 public boolean testNotEq31_2(MyValue v, MyInterface[] a) { 988 return v != get(a); // only false if both null 989 } 990 991 public boolean testNotEq31_3(MyValue v, MyInterface[] a) { 992 return get(v) != get(a); // only false if both null 993 } 994 995 public boolean testNotEq32_1(MyInterface[] a, MyValue v) { 996 return getNotNull(a) != v; // true 997 } 998 999 public boolean testNotEq32_2(MyInterface[] a, MyValue v) { 1000 return a != getNotNull(v); // true 1001 } 1002 1003 public boolean testNotEq32_3(MyInterface[] a, MyValue v) { 1004 return getNotNull(a) != getNotNull(v); // true 1005 } 1006 1007 public boolean testNotEq33_1(MyValue v, MyInterface[] a) { 1008 return getNotNull(v) != a; // true 1009 } 1010 1011 public boolean testNotEq33_2(MyValue v, MyInterface[] a) { 1012 return v != getNotNull(a); // true 1013 } 1014 1015 public boolean testNotEq33_3(MyValue v, MyInterface[] a) { 1016 return getNotNull(v) != getNotNull(a); // true 1017 } 1018 1019 // Null tests 1020 1021 public boolean testNotNull01_1(MyValue v) { 1022 return v != null; // old acmp 1023 } 1024 1025 public boolean testNotNull01_2(MyValue v) { 1026 return get(v) != null; // old acmp 1027 } 1028 1029 public boolean testNotNull01_3(MyValue v) { 1030 return v != get((Object)null); // old acmp 1031 } 1032 1033 public boolean testNotNull01_4(MyValue v) { 1034 return get(v) != get((Object)null); // old acmp 1035 } 1036 1037 public boolean testNotNull02_1(MyValue v) { 1038 return null != v; // old acmp 1039 } 1040 1041 public boolean testNotNull02_2(MyValue v) { 1042 return get((Object)null) != v; // old acmp 1043 } 1044 1045 public boolean testNotNull02_3(MyValue v) { 1046 return null != get(v); // old acmp 1047 } 1048 1049 public boolean testNotNull02_4(MyValue v) { 1050 return get((Object)null) != get(v); // old acmp 1051 } 1052 1053 public boolean testNotNull03_1(Object u) { 1054 return u != null; // old acmp 1055 } 1056 1057 public boolean testNotNull03_2(Object u) { 1058 return get(u) != null; // old acmp 1059 } 1060 1061 public boolean testNotNull03_3(Object u) { 1062 return u != get((Object)null); // old acmp 1063 } 1064 1065 public boolean testNotNull03_4(Object u) { 1066 return get(u) != get((Object)null); // old acmp 1067 } 1068 1069 public boolean testNotNull04_1(Object u) { 1070 return null != u; // old acmp 1071 } 1072 1073 public boolean testNotNull04_2(Object u) { 1074 return get((Object)null) != u; // old acmp 1075 } 1076 1077 public boolean testNotNull04_3(Object u) { 1078 return null != get(u); // old acmp 1079 } 1080 1081 public boolean testNotNull04_4(Object u) { 1082 return get((Object)null) != get(u); // old acmp 1083 } 1084 1085 public boolean testNotNull05_1(MyObject o) { 1086 return o != null; // old acmp 1087 } 1088 1089 public boolean testNotNull05_2(MyObject o) { 1090 return get(o) != null; // old acmp 1091 } 1092 1093 public boolean testNotNull05_3(MyObject o) { 1094 return o != get((Object)null); // old acmp 1095 } 1096 1097 public boolean testNotNull05_4(MyObject o) { 1098 return get(o) != get((Object)null); // old acmp 1099 } 1100 1101 public boolean testNotNull06_1(MyObject o) { 1102 return null != o; // old acmp 1103 } 1104 1105 public boolean testNotNull06_2(MyObject o) { 1106 return get((Object)null) != o; // old acmp 1107 } 1108 1109 public boolean testNotNull06_3(MyObject o) { 1110 return null != get(o); // old acmp 1111 } 1112 1113 public boolean testNotNull06_4(MyObject o) { 1114 return get((Object)null) != get(o); // old acmp 1115 } 1116 1117 public boolean testNotNull07_1(MyInterface u) { 1118 return u != null; // old acmp 1119 } 1120 1121 public boolean testNotNull07_2(MyInterface u) { 1122 return get(u) != null; // old acmp 1123 } 1124 1125 public boolean testNotNull07_3(MyInterface u) { 1126 return u != get((Object)null); // old acmp 1127 } 1128 1129 public boolean testNotNull07_4(MyInterface u) { 1130 return get(u) != get((Object)null); // old acmp 1131 } 1132 1133 public boolean testNotNull08_1(MyInterface u) { 1134 return null != u; // old acmp 1135 } 1136 1137 public boolean testNotNull08_2(MyInterface u) { 1138 return get((Object)null) != u; // old acmp 1139 } 1140 1141 public boolean testNotNull08_3(MyInterface u) { 1142 return null != get(u); // old acmp 1143 } 1144 1145 public boolean testNotNull08_4(MyInterface u) { 1146 return get((Object)null) != get(u); // old acmp 1147 } 1148 1149 // The following methods are used with -XX:+AlwaysIncrementalInline to hide exact types during parsing 1150 1151 public Object get(Object u) { 1152 return u; 1153 } 1154 1155 public Object getNotNull(Object u) { 1156 return (u != null) ? u : new Object(); 1157 } 1158 1159 public Object get(MyValue v) { 1160 return v; 1161 } 1162 1163 public Object getNotNull(MyValue v) { 1164 return (v != null) ? v : new MyValue(); 1165 } 1166 1167 public Object get(MyObject o) { 1168 return o; 1169 } 1170 1171 public Object getNotNull(MyObject o) { 1172 return (o != null) ? o : new MyObject(); 1173 } 1174 1175 public Object get(Object[] a) { 1176 return a; 1177 } 1178 1179 public Object getNotNull(Object[] a) { 1180 return (a != null) ? a : new Object[1]; 1181 } 1182 1183 public boolean falseIfNull(Method m) { 1184 String name = m.getName(); 1185 Pattern pattern = Pattern.compile("(01_4|01_5|01_6|21_4|21_5|21_6)$"); 1186 Matcher matcher = pattern.matcher(name); 1187 return matcher.find(); 1188 } 1189 1190 public boolean alwaysFalse(Method m) { 1191 String name = m.getName(); 1192 Pattern pattern = Pattern.compile("(07_1|07_2|07_3|08_1|08_2|08_3|09_1|09_2|09_3|10_1|10_2|10_3|11_1|11_2|11_3|19_1|19_2|19_3|20_1|20_2|20_3|24_1|24_2|24_3|25_1|25_2|25_3|32_1|32_2|32_3|33_1|33_2|33_3)$"); 1193 Matcher matcher = pattern.matcher(name); 1194 return matcher.find(); 1195 } 1196 1197 public void runMethod(Method m, Object[] args, int warmup) throws Exception { 1198 Class<?>[] parameterTypes = m.getParameterTypes(); 1199 int parameterCount = parameterTypes.length; 1200 for (int i = 0; i < args.length; ++i) { 1201 if (args[i] != null && !parameterTypes[0].isInstance(args[i])) { 1202 continue; 1203 } 1204 if (parameterCount == 1) { 1205 // Null checks 1206 System.out.print("Testing " + m.getName() + "(" + args[i] + ")"); 1207 boolean negated = m.getName().startsWith("testNot"); 1208 boolean expected = args[i] == null; 1209 if (negated) expected = !expected; 1210 for (int run = 0; run < warmup; ++run) { 1211 Boolean result = (Boolean)m.invoke(this, args[i]); 1212 if (result != expected) { 1213 System.out.println(" = " + result); 1214 throw new RuntimeException("Test failed: should return " + expected); 1215 } 1216 } 1217 System.out.println(" = " + expected); 1218 } else { 1219 // Equality checks 1220 for (int j = 0; j < args.length; ++j) { 1221 if (args[j] != null && !parameterTypes[1].isInstance(args[j])) { 1222 continue; 1223 } 1224 System.out.print("Testing " + m.getName() + "(" + args[i] + ", " + args[j] + ")"); 1225 boolean negated = m.getName().startsWith("testNot"); 1226 boolean expected = (i == j) && !(args[i] instanceof MyValue) && !alwaysFalse(m) && !((args[i] == null || args[j] == null) && falseIfNull(m)); 1227 if (negated) expected = !expected; 1228 for (int run = 0; run < warmup; ++run) { 1229 Boolean result = (Boolean)m.invoke(this, args[i], args[j]); 1230 if (result != expected) { 1231 System.out.println(" = " + result); 1232 throw new RuntimeException("Test failed: should return " + expected); 1233 } 1234 } 1235 System.out.println(" = " + expected); 1236 } 1237 } 1238 } 1239 } 1240 1241 public void run() throws Exception { 1242 Object[] args = new Object[5]; 1243 args[0] = null; 1244 args[1] = new Object(); 1245 args[2] = new MyObject(); 1246 args[3] = new MyValue(); 1247 args[4] = new Object[10]; 1248 1249 for (Method m : getClass().getMethods()) { 1250 if (m.getName().startsWith("test")) { 1251 // runMethod(m, args, 100_000); 1252 runMethod(m, args, 10_000); 1253 } 1254 } 1255 } 1256 1257 public static void main(String[] args) throws Exception { 1258 Test t = new Test(); 1259 t.run(); 1260 } 1261 } 1262