Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
12 |
|
12 |
|
|
|
13 |
import java.io.File; |
14 |
import java.io.IOException; |
15 |
|
16 |
import org.eclipse.jdt.core.ToolFactory; |
17 |
import org.eclipse.jdt.core.tests.util.Util; |
18 |
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; |
19 |
|
13 |
import junit.framework.Test; |
20 |
import junit.framework.Test; |
14 |
import junit.framework.TestSuite; |
21 |
import junit.framework.TestSuite; |
15 |
|
22 |
|
Lines 414-419
Link Here
|
414 |
}, |
421 |
}, |
415 |
"SUCCESS"); |
422 |
"SUCCESS"); |
416 |
} |
423 |
} |
|
|
424 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 |
425 |
public void test018() { |
426 |
this.runConformTest( |
427 |
new String[] { |
428 |
"X.java", |
429 |
"public class X {\n" + |
430 |
" public static float f0;\n" + |
431 |
" \n" + |
432 |
" public static void main(String[] args)\n" + |
433 |
" {\n" + |
434 |
" long l11 = -26;\n" + |
435 |
" \n" + |
436 |
" System.out.println(\n" + |
437 |
" (((l11 < f0++) || true) != ((true && true) && (!(false || true)))));\n" + |
438 |
" }\n" + |
439 |
"}\n", |
440 |
}, |
441 |
"true"); |
442 |
// ensure optimized boolean codegen sequence |
443 |
String expectedOutput = |
444 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
445 |
" // Stack: 3, Locals: 3\n" + |
446 |
" public static void main(java.lang.String[] args);\n" + |
447 |
" 0 ldc2_w <Long -26> [18]\n" + |
448 |
" 3 lstore_1 [l11]\n" + |
449 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
450 |
" 7 getstatic X.f0 : float [26]\n" + |
451 |
" 10 fconst_1\n" + |
452 |
" 11 fadd\n" + |
453 |
" 12 putstatic X.f0 : float [26]\n" + |
454 |
" 15 iconst_1\n" + |
455 |
" 16 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" + |
456 |
" 19 return\n" + |
457 |
" Line numbers:\n" + |
458 |
" [pc: 0, line: 6]\n" + |
459 |
" [pc: 4, line: 8]\n" + |
460 |
" [pc: 7, line: 9]\n" + |
461 |
" [pc: 16, line: 8]\n" + |
462 |
" [pc: 19, line: 10]\n" + |
463 |
" Local variable table:\n" + |
464 |
" [pc: 0, pc: 20] local: args index: 0 type: java.lang.String[]\n" + |
465 |
" [pc: 4, pc: 20] local: l11 index: 1 type: long\n"; |
466 |
|
467 |
try { |
468 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
469 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
470 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
471 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
472 |
int index = result.indexOf(expectedOutput); |
473 |
if (index == -1 || expectedOutput.length() == 0) { |
474 |
System.out.println(Util.displayString(result, 3)); |
475 |
} |
476 |
if (index == -1) { |
477 |
assertEquals("Wrong contents", expectedOutput, result); |
478 |
} |
479 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
480 |
assertTrue(false); |
481 |
} catch (IOException e) { |
482 |
assertTrue(false); |
483 |
} |
484 |
} |
485 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
486 |
public void test019() { |
487 |
this.runConformTest( |
488 |
new String[] { |
489 |
"X.java", |
490 |
"public class X {\n" + |
491 |
" public static float f0;\n" + |
492 |
" \n" + |
493 |
" public static void main(String[] args)\n" + |
494 |
" {\n" + |
495 |
" long l11 = -26;\n" + |
496 |
" \n" + |
497 |
" System.out.println(\n" + |
498 |
" (((l11 < f0++) || false) != true));\n" + |
499 |
" }\n" + |
500 |
"}\n", |
501 |
}, |
502 |
"false"); |
503 |
// ensure optimized boolean codegen sequence |
504 |
String expectedOutput = |
505 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
506 |
" // Stack: 5, Locals: 3\n" + |
507 |
" public static void main(java.lang.String[] args);\n" + |
508 |
" 0 ldc2_w <Long -26> [18]\n" + |
509 |
" 3 lstore_1 [l11]\n" + |
510 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
511 |
" 7 lload_1 [l11]\n" + |
512 |
" 8 l2f\n" + |
513 |
" 9 getstatic X.f0 : float [26]\n" + |
514 |
" 12 dup\n" + |
515 |
" 13 fconst_1\n" + |
516 |
" 14 fadd\n" + |
517 |
" 15 putstatic X.f0 : float [26]\n" + |
518 |
" 18 fcmpg\n" + |
519 |
" 19 ifge 26\n" + |
520 |
" 22 iconst_0\n" + |
521 |
" 23 goto 27\n" + |
522 |
" 26 iconst_1\n" + |
523 |
" 27 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" + |
524 |
" 30 return\n" + |
525 |
" Line numbers:\n" + |
526 |
" [pc: 0, line: 6]\n" + |
527 |
" [pc: 4, line: 8]\n" + |
528 |
" [pc: 7, line: 9]\n" + |
529 |
" [pc: 27, line: 8]\n" + |
530 |
" [pc: 30, line: 10]\n" + |
531 |
" Local variable table:\n" + |
532 |
" [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" + |
533 |
" [pc: 4, pc: 31] local: l11 index: 1 type: long\n"; |
534 |
|
535 |
try { |
536 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
537 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
538 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
539 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
540 |
int index = result.indexOf(expectedOutput); |
541 |
if (index == -1 || expectedOutput.length() == 0) { |
542 |
System.out.println(Util.displayString(result, 3)); |
543 |
} |
544 |
if (index == -1) { |
545 |
assertEquals("Wrong contents", expectedOutput, result); |
546 |
} |
547 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
548 |
assertTrue(false); |
549 |
} catch (IOException e) { |
550 |
assertTrue(false); |
551 |
} |
552 |
} |
553 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
554 |
public void test020() { |
555 |
this.runConformTest( |
556 |
new String[] { |
557 |
"X.java", |
558 |
"public class X {\n" + |
559 |
" public static float f0;\n" + |
560 |
" \n" + |
561 |
" public static void main(String[] args)\n" + |
562 |
" {\n" + |
563 |
" long l11 = -26;\n" + |
564 |
" \n" + |
565 |
" System.out.println(\n" + |
566 |
" (((l11 < f0) | true) != false));\n" + |
567 |
" }\n" + |
568 |
"}\n", |
569 |
}, |
570 |
"true"); |
571 |
// ensure optimized boolean codegen sequence |
572 |
String expectedOutput = |
573 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
574 |
" // Stack: 2, Locals: 3\n" + |
575 |
" public static void main(java.lang.String[] args);\n" + |
576 |
" 0 ldc2_w <Long -26> [18]\n" + |
577 |
" 3 lstore_1 [l11]\n" + |
578 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
579 |
" 7 iconst_1\n" + |
580 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
581 |
" 11 return\n" + |
582 |
" Line numbers:\n" + |
583 |
" [pc: 0, line: 6]\n" + |
584 |
" [pc: 4, line: 8]\n" + |
585 |
" [pc: 7, line: 9]\n" + |
586 |
" [pc: 8, line: 8]\n" + |
587 |
" [pc: 11, line: 10]\n" + |
588 |
" Local variable table:\n" + |
589 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
590 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
591 |
|
592 |
try { |
593 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
594 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
595 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
596 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
597 |
int index = result.indexOf(expectedOutput); |
598 |
if (index == -1 || expectedOutput.length() == 0) { |
599 |
System.out.println(Util.displayString(result, 3)); |
600 |
} |
601 |
if (index == -1) { |
602 |
assertEquals("Wrong contents", expectedOutput, result); |
603 |
} |
604 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
605 |
assertTrue(false); |
606 |
} catch (IOException e) { |
607 |
assertTrue(false); |
608 |
} |
609 |
} |
610 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
611 |
public void test021() { |
612 |
this.runConformTest( |
613 |
new String[] { |
614 |
"X.java", |
615 |
"public class X {\n" + |
616 |
" public static float f0;\n" + |
617 |
" \n" + |
618 |
" public static void main(String[] args)\n" + |
619 |
" {\n" + |
620 |
" long l11 = -26;\n" + |
621 |
" \n" + |
622 |
" System.out.println(\n" + |
623 |
" (((l11 < f0) && false) != true));\n" + |
624 |
" }\n" + |
625 |
"}\n", |
626 |
}, |
627 |
"true"); |
628 |
// ensure optimized boolean codegen sequence |
629 |
String expectedOutput = |
630 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
631 |
" // Stack: 2, Locals: 3\n" + |
632 |
" public static void main(java.lang.String[] args);\n" + |
633 |
" 0 ldc2_w <Long -26> [18]\n" + |
634 |
" 3 lstore_1 [l11]\n" + |
635 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
636 |
" 7 iconst_1\n" + |
637 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
638 |
" 11 return\n" + |
639 |
" Line numbers:\n" + |
640 |
" [pc: 0, line: 6]\n" + |
641 |
" [pc: 4, line: 8]\n" + |
642 |
" [pc: 7, line: 9]\n" + |
643 |
" [pc: 8, line: 8]\n" + |
644 |
" [pc: 11, line: 10]\n" + |
645 |
" Local variable table:\n" + |
646 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
647 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
648 |
|
649 |
try { |
650 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
651 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
652 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
653 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
654 |
int index = result.indexOf(expectedOutput); |
655 |
if (index == -1 || expectedOutput.length() == 0) { |
656 |
System.out.println(Util.displayString(result, 3)); |
657 |
} |
658 |
if (index == -1) { |
659 |
assertEquals("Wrong contents", expectedOutput, result); |
660 |
} |
661 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
662 |
assertTrue(false); |
663 |
} catch (IOException e) { |
664 |
assertTrue(false); |
665 |
} |
666 |
} |
667 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
668 |
public void test022() { |
669 |
this.runConformTest( |
670 |
new String[] { |
671 |
"X.java", |
672 |
"public class X {\n" + |
673 |
" public static float f0;\n" + |
674 |
" \n" + |
675 |
" public static void main(String[] args)\n" + |
676 |
" {\n" + |
677 |
" long l11 = -26;\n" + |
678 |
" \n" + |
679 |
" System.out.println(\n" + |
680 |
" (((l11 < f0) & false) != true));\n" + |
681 |
" }\n" + |
682 |
"}\n", |
683 |
}, |
684 |
"true"); |
685 |
// ensure optimized boolean codegen sequence |
686 |
String expectedOutput = |
687 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
688 |
" // Stack: 2, Locals: 3\n" + |
689 |
" public static void main(java.lang.String[] args);\n" + |
690 |
" 0 ldc2_w <Long -26> [18]\n" + |
691 |
" 3 lstore_1 [l11]\n" + |
692 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
693 |
" 7 iconst_1\n" + |
694 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
695 |
" 11 return\n" + |
696 |
" Line numbers:\n" + |
697 |
" [pc: 0, line: 6]\n" + |
698 |
" [pc: 4, line: 8]\n" + |
699 |
" [pc: 7, line: 9]\n" + |
700 |
" [pc: 8, line: 8]\n" + |
701 |
" [pc: 11, line: 10]\n" + |
702 |
" Local variable table:\n" + |
703 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
704 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
705 |
|
706 |
try { |
707 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
708 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
709 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
710 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
711 |
int index = result.indexOf(expectedOutput); |
712 |
if (index == -1 || expectedOutput.length() == 0) { |
713 |
System.out.println(Util.displayString(result, 3)); |
714 |
} |
715 |
if (index == -1) { |
716 |
assertEquals("Wrong contents", expectedOutput, result); |
717 |
} |
718 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
719 |
assertTrue(false); |
720 |
} catch (IOException e) { |
721 |
assertTrue(false); |
722 |
} |
723 |
} |
724 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 |
725 |
public void test023() { |
726 |
this.runConformTest( |
727 |
new String[] { |
728 |
"X.java", |
729 |
"public class X {\n" + |
730 |
" public static float f0;\n" + |
731 |
" \n" + |
732 |
" public static void main(String[] args)\n" + |
733 |
" {\n" + |
734 |
" long l11 = -26;\n" + |
735 |
" \n" + |
736 |
" System.out.println(\n" + |
737 |
" (((l11 < f0++) || true) == ((true && true) && (!(false || true)))));\n" + |
738 |
" }\n" + |
739 |
"}\n", |
740 |
}, |
741 |
"false"); |
742 |
// ensure optimized boolean codegen sequence |
743 |
String expectedOutput = |
744 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
745 |
" // Stack: 3, Locals: 3\n" + |
746 |
" public static void main(java.lang.String[] args);\n" + |
747 |
" 0 ldc2_w <Long -26> [18]\n" + |
748 |
" 3 lstore_1 [l11]\n" + |
749 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
750 |
" 7 getstatic X.f0 : float [26]\n" + |
751 |
" 10 fconst_1\n" + |
752 |
" 11 fadd\n" + |
753 |
" 12 putstatic X.f0 : float [26]\n" + |
754 |
" 15 iconst_0\n" + |
755 |
" 16 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" + |
756 |
" 19 return\n" + |
757 |
" Line numbers:\n" + |
758 |
" [pc: 0, line: 6]\n" + |
759 |
" [pc: 4, line: 8]\n" + |
760 |
" [pc: 7, line: 9]\n" + |
761 |
" [pc: 16, line: 8]\n" + |
762 |
" [pc: 19, line: 10]\n" + |
763 |
" Local variable table:\n" + |
764 |
" [pc: 0, pc: 20] local: args index: 0 type: java.lang.String[]\n" + |
765 |
" [pc: 4, pc: 20] local: l11 index: 1 type: long\n"; |
766 |
|
767 |
try { |
768 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
769 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
770 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
771 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
772 |
int index = result.indexOf(expectedOutput); |
773 |
if (index == -1 || expectedOutput.length() == 0) { |
774 |
System.out.println(Util.displayString(result, 3)); |
775 |
} |
776 |
if (index == -1) { |
777 |
assertEquals("Wrong contents", expectedOutput, result); |
778 |
} |
779 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
780 |
assertTrue(false); |
781 |
} catch (IOException e) { |
782 |
assertTrue(false); |
783 |
} |
784 |
} |
785 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
786 |
public void test024() { |
787 |
this.runConformTest( |
788 |
new String[] { |
789 |
"X.java", |
790 |
"public class X {\n" + |
791 |
" public static float f0;\n" + |
792 |
" \n" + |
793 |
" public static void main(String[] args)\n" + |
794 |
" {\n" + |
795 |
" long l11 = -26;\n" + |
796 |
" \n" + |
797 |
" System.out.println(\n" + |
798 |
" (((l11 < f0++) || false) == true));\n" + |
799 |
" }\n" + |
800 |
"}\n", |
801 |
}, |
802 |
"true"); |
803 |
// ensure optimized boolean codegen sequence |
804 |
String expectedOutput = |
805 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
806 |
" // Stack: 5, Locals: 3\n" + |
807 |
" public static void main(java.lang.String[] args);\n" + |
808 |
" 0 ldc2_w <Long -26> [18]\n" + |
809 |
" 3 lstore_1 [l11]\n" + |
810 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
811 |
" 7 lload_1 [l11]\n" + |
812 |
" 8 l2f\n" + |
813 |
" 9 getstatic X.f0 : float [26]\n" + |
814 |
" 12 dup\n" + |
815 |
" 13 fconst_1\n" + |
816 |
" 14 fadd\n" + |
817 |
" 15 putstatic X.f0 : float [26]\n" + |
818 |
" 18 fcmpg\n" + |
819 |
" 19 ifge 26\n" + |
820 |
" 22 iconst_1\n" + |
821 |
" 23 goto 27\n" + |
822 |
" 26 iconst_0\n" + |
823 |
" 27 invokevirtual java.io.PrintStream.println(boolean) : void [28]\n" + |
824 |
" 30 return\n" + |
825 |
" Line numbers:\n" + |
826 |
" [pc: 0, line: 6]\n" + |
827 |
" [pc: 4, line: 8]\n" + |
828 |
" [pc: 7, line: 9]\n" + |
829 |
" [pc: 27, line: 8]\n" + |
830 |
" [pc: 30, line: 10]\n" + |
831 |
" Local variable table:\n" + |
832 |
" [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" + |
833 |
" [pc: 4, pc: 31] local: l11 index: 1 type: long\n"; |
834 |
|
835 |
try { |
836 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
837 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
838 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
839 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
840 |
int index = result.indexOf(expectedOutput); |
841 |
if (index == -1 || expectedOutput.length() == 0) { |
842 |
System.out.println(Util.displayString(result, 3)); |
843 |
} |
844 |
if (index == -1) { |
845 |
assertEquals("Wrong contents", expectedOutput, result); |
846 |
} |
847 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
848 |
assertTrue(false); |
849 |
} catch (IOException e) { |
850 |
assertTrue(false); |
851 |
} |
852 |
} |
853 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
854 |
public void test025() { |
855 |
this.runConformTest( |
856 |
new String[] { |
857 |
"X.java", |
858 |
"public class X {\n" + |
859 |
" public static float f0;\n" + |
860 |
" \n" + |
861 |
" public static void main(String[] args)\n" + |
862 |
" {\n" + |
863 |
" long l11 = -26;\n" + |
864 |
" \n" + |
865 |
" System.out.println(\n" + |
866 |
" (((l11 < f0) | true) == false));\n" + |
867 |
" }\n" + |
868 |
"}\n", |
869 |
}, |
870 |
"false"); |
871 |
// ensure optimized boolean codegen sequence |
872 |
String expectedOutput = |
873 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
874 |
" // Stack: 2, Locals: 3\n" + |
875 |
" public static void main(java.lang.String[] args);\n" + |
876 |
" 0 ldc2_w <Long -26> [18]\n" + |
877 |
" 3 lstore_1 [l11]\n" + |
878 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
879 |
" 7 iconst_0\n" + |
880 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
881 |
" 11 return\n" + |
882 |
" Line numbers:\n" + |
883 |
" [pc: 0, line: 6]\n" + |
884 |
" [pc: 4, line: 8]\n" + |
885 |
" [pc: 7, line: 9]\n" + |
886 |
" [pc: 8, line: 8]\n" + |
887 |
" [pc: 11, line: 10]\n" + |
888 |
" Local variable table:\n" + |
889 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
890 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
891 |
|
892 |
try { |
893 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
894 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
895 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
896 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
897 |
int index = result.indexOf(expectedOutput); |
898 |
if (index == -1 || expectedOutput.length() == 0) { |
899 |
System.out.println(Util.displayString(result, 3)); |
900 |
} |
901 |
if (index == -1) { |
902 |
assertEquals("Wrong contents", expectedOutput, result); |
903 |
} |
904 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
905 |
assertTrue(false); |
906 |
} catch (IOException e) { |
907 |
assertTrue(false); |
908 |
} |
909 |
} |
910 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
911 |
public void test026() { |
912 |
this.runConformTest( |
913 |
new String[] { |
914 |
"X.java", |
915 |
"public class X {\n" + |
916 |
" public static float f0;\n" + |
917 |
" \n" + |
918 |
" public static void main(String[] args)\n" + |
919 |
" {\n" + |
920 |
" long l11 = -26;\n" + |
921 |
" \n" + |
922 |
" System.out.println(\n" + |
923 |
" (((l11 < f0) && false) == true));\n" + |
924 |
" }\n" + |
925 |
"}\n", |
926 |
}, |
927 |
"false"); |
928 |
// ensure optimized boolean codegen sequence |
929 |
String expectedOutput = |
930 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
931 |
" // Stack: 2, Locals: 3\n" + |
932 |
" public static void main(java.lang.String[] args);\n" + |
933 |
" 0 ldc2_w <Long -26> [18]\n" + |
934 |
" 3 lstore_1 [l11]\n" + |
935 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
936 |
" 7 iconst_0\n" + |
937 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
938 |
" 11 return\n" + |
939 |
" Line numbers:\n" + |
940 |
" [pc: 0, line: 6]\n" + |
941 |
" [pc: 4, line: 8]\n" + |
942 |
" [pc: 7, line: 9]\n" + |
943 |
" [pc: 8, line: 8]\n" + |
944 |
" [pc: 11, line: 10]\n" + |
945 |
" Local variable table:\n" + |
946 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
947 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n" + |
948 |
"}"; |
949 |
|
950 |
try { |
951 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
952 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
953 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
954 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
955 |
int index = result.indexOf(expectedOutput); |
956 |
if (index == -1 || expectedOutput.length() == 0) { |
957 |
System.out.println(Util.displayString(result, 3)); |
958 |
} |
959 |
if (index == -1) { |
960 |
assertEquals("Wrong contents", expectedOutput, result); |
961 |
} |
962 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
963 |
assertTrue(false); |
964 |
} catch (IOException e) { |
965 |
assertTrue(false); |
966 |
} |
967 |
} |
968 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
969 |
public void test027() { |
970 |
this.runConformTest( |
971 |
new String[] { |
972 |
"X.java", |
973 |
"public class X {\n" + |
974 |
" public static float f0;\n" + |
975 |
" \n" + |
976 |
" public static void main(String[] args)\n" + |
977 |
" {\n" + |
978 |
" long l11 = -26;\n" + |
979 |
" \n" + |
980 |
" System.out.println(\n" + |
981 |
" (((l11 < f0) & false) == true));\n" + |
982 |
" }\n" + |
983 |
"}\n", |
984 |
}, |
985 |
"false"); |
986 |
// ensure optimized boolean codegen sequence |
987 |
String expectedOutput = |
988 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
989 |
" // Stack: 2, Locals: 3\n" + |
990 |
" public static void main(java.lang.String[] args);\n" + |
991 |
" 0 ldc2_w <Long -26> [18]\n" + |
992 |
" 3 lstore_1 [l11]\n" + |
993 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
994 |
" 7 iconst_0\n" + |
995 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
996 |
" 11 return\n" + |
997 |
" Line numbers:\n" + |
998 |
" [pc: 0, line: 6]\n" + |
999 |
" [pc: 4, line: 8]\n" + |
1000 |
" [pc: 7, line: 9]\n" + |
1001 |
" [pc: 8, line: 8]\n" + |
1002 |
" [pc: 11, line: 10]\n" + |
1003 |
" Local variable table:\n" + |
1004 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
1005 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
1006 |
|
1007 |
try { |
1008 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1009 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
1010 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
1011 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
1012 |
int index = result.indexOf(expectedOutput); |
1013 |
if (index == -1 || expectedOutput.length() == 0) { |
1014 |
System.out.println(Util.displayString(result, 3)); |
1015 |
} |
1016 |
if (index == -1) { |
1017 |
assertEquals("Wrong contents", expectedOutput, result); |
1018 |
} |
1019 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
1020 |
assertTrue(false); |
1021 |
} catch (IOException e) { |
1022 |
assertTrue(false); |
1023 |
} |
1024 |
} |
1025 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
1026 |
public void test028() { |
1027 |
this.runConformTest( |
1028 |
new String[] { |
1029 |
"X.java", |
1030 |
"public class X {\n" + |
1031 |
" public static float f0;\n" + |
1032 |
" \n" + |
1033 |
" public static void main(String[] args)\n" + |
1034 |
" {\n" + |
1035 |
" long l11 = -26;\n" + |
1036 |
" \n" + |
1037 |
" System.out.println(\n" + |
1038 |
" (((l11 < f0) || true) == false));\n" + |
1039 |
" }\n" + |
1040 |
"}\n", |
1041 |
}, |
1042 |
"false"); |
1043 |
// ensure optimized boolean codegen sequence |
1044 |
String expectedOutput = |
1045 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
1046 |
" // Stack: 2, Locals: 3\n" + |
1047 |
" public static void main(java.lang.String[] args);\n" + |
1048 |
" 0 ldc2_w <Long -26> [18]\n" + |
1049 |
" 3 lstore_1 [l11]\n" + |
1050 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
1051 |
" 7 iconst_0\n" + |
1052 |
" 8 invokevirtual java.io.PrintStream.println(boolean) : void [26]\n" + |
1053 |
" 11 return\n" + |
1054 |
" Line numbers:\n" + |
1055 |
" [pc: 0, line: 6]\n" + |
1056 |
" [pc: 4, line: 8]\n" + |
1057 |
" [pc: 7, line: 9]\n" + |
1058 |
" [pc: 8, line: 8]\n" + |
1059 |
" [pc: 11, line: 10]\n" + |
1060 |
" Local variable table:\n" + |
1061 |
" [pc: 0, pc: 12] local: args index: 0 type: java.lang.String[]\n" + |
1062 |
" [pc: 4, pc: 12] local: l11 index: 1 type: long\n"; |
1063 |
|
1064 |
try { |
1065 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1066 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
1067 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
1068 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
1069 |
int index = result.indexOf(expectedOutput); |
1070 |
if (index == -1 || expectedOutput.length() == 0) { |
1071 |
System.out.println(Util.displayString(result, 3)); |
1072 |
} |
1073 |
if (index == -1) { |
1074 |
assertEquals("Wrong contents", expectedOutput, result); |
1075 |
} |
1076 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
1077 |
assertTrue(false); |
1078 |
} catch (IOException e) { |
1079 |
assertTrue(false); |
1080 |
} |
1081 |
} |
1082 |
|
1083 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
1084 |
public void test029() { |
1085 |
this.runConformTest( |
1086 |
new String[] { |
1087 |
"X.java", |
1088 |
"public class X {\n" + |
1089 |
" public static float f0;\n" + |
1090 |
" \n" + |
1091 |
" public static void main(String[] args)\n" + |
1092 |
" {\n" + |
1093 |
" System.out.println(\n" + |
1094 |
" ((foo() || bar()) || true) && false); \n" + |
1095 |
" }\n" + |
1096 |
" static boolean foo(){ \n" + |
1097 |
" System.out.print(\"foo\");\n" + |
1098 |
" return false;\n" + |
1099 |
" }\n" + |
1100 |
" static boolean bar(){\n" + |
1101 |
" System.out.print(\"bar\");\n" + |
1102 |
" return true;\n" + |
1103 |
" }\n" + |
1104 |
"}\n", |
1105 |
}, |
1106 |
"foobarfalse"); |
1107 |
// ensure optimized boolean codegen sequence |
1108 |
String expectedOutput = |
1109 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
1110 |
" // Stack: 2, Locals: 1\n" + |
1111 |
" public static void main(java.lang.String[] args);\n" + |
1112 |
" 0 getstatic java.lang.System.out : java.io.PrintStream [18]\n" + |
1113 |
" 3 invokestatic X.foo() : boolean [24]\n" + |
1114 |
" 6 ifne 13\n" + |
1115 |
" 9 invokestatic X.bar() : boolean [28]\n" + |
1116 |
" 12 pop\n" + |
1117 |
" 13 iconst_0\n" + |
1118 |
" 14 invokevirtual java.io.PrintStream.println(boolean) : void [31]\n" + |
1119 |
" 17 return\n" + |
1120 |
" Line numbers:\n" + |
1121 |
" [pc: 0, line: 6]\n" + |
1122 |
" [pc: 3, line: 7]\n" + |
1123 |
" [pc: 14, line: 6]\n" + |
1124 |
" [pc: 17, line: 8]\n" + |
1125 |
" Local variable table:\n" + |
1126 |
" [pc: 0, pc: 18] local: args index: 0 type: java.lang.String[]\n"; |
1127 |
|
1128 |
try { |
1129 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1130 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
1131 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
1132 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
1133 |
int index = result.indexOf(expectedOutput); |
1134 |
if (index == -1 || expectedOutput.length() == 0) { |
1135 |
System.out.println(Util.displayString(result, 3)); |
1136 |
} |
1137 |
if (index == -1) { |
1138 |
assertEquals("Wrong contents", expectedOutput, result); |
1139 |
} |
1140 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
1141 |
assertTrue(false); |
1142 |
} catch (IOException e) { |
1143 |
assertTrue(false); |
1144 |
} |
1145 |
} |
1146 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=117120 - variation |
1147 |
public void test030() { |
1148 |
this.runConformTest( |
1149 |
new String[] { |
1150 |
"X.java", |
1151 |
"public class X {\n" + |
1152 |
" public static float f0;\n" + |
1153 |
" \n" + |
1154 |
" public static void main(String[] args)\n" + |
1155 |
" {\n" + |
1156 |
" long l11 = -26;\n" + |
1157 |
" \n" + |
1158 |
" System.out.println(\n" + |
1159 |
" (((l11 < f0++) || true) == ((foo() || bar()) || true)));\n" + |
1160 |
" }\n" + |
1161 |
" static boolean foo() {\n" + |
1162 |
" System.out.print(\"foo\");\n" + |
1163 |
" return false;\n" + |
1164 |
" }\n" + |
1165 |
" static boolean bar() {\n" + |
1166 |
" System.out.print(\"bar\");\n" + |
1167 |
" return true;\n" + |
1168 |
" }\n" + |
1169 |
"}\n", |
1170 |
}, |
1171 |
"foobartrue"); |
1172 |
// ensure optimized boolean codegen sequence |
1173 |
String expectedOutput = |
1174 |
" // Method descriptor #17 ([Ljava/lang/String;)V\n" + |
1175 |
" // Stack: 3, Locals: 3\n" + |
1176 |
" public static void main(java.lang.String[] args);\n" + |
1177 |
" 0 ldc2_w <Long -26> [18]\n" + |
1178 |
" 3 lstore_1 [l11]\n" + |
1179 |
" 4 getstatic java.lang.System.out : java.io.PrintStream [20]\n" + |
1180 |
" 7 getstatic X.f0 : float [26]\n" + |
1181 |
" 10 fconst_1\n" + |
1182 |
" 11 fadd\n" + |
1183 |
" 12 putstatic X.f0 : float [26]\n" + |
1184 |
" 15 invokestatic X.foo() : boolean [28]\n" + |
1185 |
" 18 ifne 25\n" + |
1186 |
" 21 invokestatic X.bar() : boolean [32]\n" + |
1187 |
" 24 pop\n" + |
1188 |
" 25 iconst_1\n" + |
1189 |
" 26 invokevirtual java.io.PrintStream.println(boolean) : void [35]\n" + |
1190 |
" 29 return\n" + |
1191 |
" Line numbers:\n" + |
1192 |
" [pc: 0, line: 6]\n" + |
1193 |
" [pc: 4, line: 8]\n" + |
1194 |
" [pc: 7, line: 9]\n" + |
1195 |
" [pc: 26, line: 8]\n" + |
1196 |
" [pc: 29, line: 10]\n" + |
1197 |
" Local variable table:\n" + |
1198 |
" [pc: 0, pc: 30] local: args index: 0 type: java.lang.String[]\n" + |
1199 |
" [pc: 4, pc: 30] local: l11 index: 1 type: long\n"; |
1200 |
|
1201 |
try { |
1202 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1203 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
1204 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
1205 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
1206 |
int index = result.indexOf(expectedOutput); |
1207 |
if (index == -1 || expectedOutput.length() == 0) { |
1208 |
System.out.println(Util.displayString(result, 3)); |
1209 |
} |
1210 |
if (index == -1) { |
1211 |
assertEquals("Wrong contents", expectedOutput, result); |
1212 |
} |
1213 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
1214 |
assertTrue(false); |
1215 |
} catch (IOException e) { |
1216 |
assertTrue(false); |
1217 |
} |
1218 |
} |
1219 |
|
417 |
public static Class testClass() { |
1220 |
public static Class testClass() { |
418 |
return BooleanTest.class; |
1221 |
return BooleanTest.class; |
419 |
} |
1222 |
} |