Lines 1506-1511
Link Here
|
1506 |
} |
1506 |
} |
1507 |
); |
1507 |
); |
1508 |
} |
1508 |
} |
|
|
1509 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=48399 - variation |
1510 |
public void test060() { |
1511 |
runNegativeTest( |
1512 |
new String[] { /* test files */ |
1513 |
"X.java", |
1514 |
"public class X {\n" + |
1515 |
" static final boolean DEBUG = false;\n" + |
1516 |
" static final int DEBUG_LEVEL = 0;\n" + |
1517 |
" boolean check() { return true; }\n" + |
1518 |
" void foo(boolean b) {\n" + |
1519 |
" if (DEBUG)\n" + |
1520 |
" System.out.println(\"fake reachable1\"); //$NON-NLS-1$\n" + |
1521 |
" if (DEBUG && b)\n" + |
1522 |
" System.out.println(\"fake reachable2\"); //$NON-NLS-1$\n" + |
1523 |
" if (DEBUG && check())\n" + |
1524 |
" System.out.println(\"fake reachable3\"); //$NON-NLS-1$\n" + |
1525 |
" if (b && DEBUG)\n" + |
1526 |
" System.out.println(\"fake reachable4\"); //$NON-NLS-1$\n" + |
1527 |
" if (check() && DEBUG)\n" + |
1528 |
" System.out.println(\"fake reachable5\"); //$NON-NLS-1$\n" + |
1529 |
" if (DEBUG_LEVEL > 1) \n" + |
1530 |
" System.out.println(\"fake reachable6\"); //$NON-NLS-1$\n" + |
1531 |
" return;\n" + |
1532 |
" return;\n" + |
1533 |
" }\n" + |
1534 |
"}\n" |
1535 |
}, |
1536 |
"----------\n" + |
1537 |
"1. WARNING in X.java (at line 8)\n" + |
1538 |
" if (DEBUG && b)\n" + |
1539 |
" ^\n" + |
1540 |
"Dead code\n" + |
1541 |
"----------\n" + |
1542 |
"2. WARNING in X.java (at line 9)\n" + |
1543 |
" System.out.println(\"fake reachable2\"); //$NON-NLS-1$\n" + |
1544 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1545 |
"Dead code\n" + |
1546 |
"----------\n" + |
1547 |
"3. WARNING in X.java (at line 10)\n" + |
1548 |
" if (DEBUG && check())\n" + |
1549 |
" ^^^^^^^\n" + |
1550 |
"Dead code\n" + |
1551 |
"----------\n" + |
1552 |
"4. WARNING in X.java (at line 11)\n" + |
1553 |
" System.out.println(\"fake reachable3\"); //$NON-NLS-1$\n" + |
1554 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1555 |
"Dead code\n" + |
1556 |
"----------\n" + |
1557 |
"5. WARNING in X.java (at line 13)\n" + |
1558 |
" System.out.println(\"fake reachable4\"); //$NON-NLS-1$\n" + |
1559 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1560 |
"Dead code\n" + |
1561 |
"----------\n" + |
1562 |
"6. WARNING in X.java (at line 15)\n" + |
1563 |
" System.out.println(\"fake reachable5\"); //$NON-NLS-1$\n" + |
1564 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1565 |
"Dead code\n" + |
1566 |
"----------\n" + |
1567 |
"7. WARNING in X.java (at line 17)\n" + |
1568 |
" System.out.println(\"fake reachable6\"); //$NON-NLS-1$\n" + |
1569 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1570 |
"Dead code\n" + |
1571 |
"----------\n" + |
1572 |
"8. ERROR in X.java (at line 19)\n" + |
1573 |
" return;\n" + |
1574 |
" ^^^^^^^\n" + |
1575 |
"Unreachable code\n" + |
1576 |
"----------\n"); |
1577 |
} |
1578 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=265962 |
1579 |
public void test061() throws Exception { |
1580 |
this.runConformTest( |
1581 |
new String[] { |
1582 |
"X.java", |
1583 |
"public class X {\n" + |
1584 |
" private static final boolean isIS() {\n" + |
1585 |
" return System.currentTimeMillis()<0 ;\n" + |
1586 |
" }\n" + |
1587 |
" public static void main(String[] args) {\n" + |
1588 |
" do {\n" + |
1589 |
" return;\n" + |
1590 |
" } while(isIS() && false);\n" + |
1591 |
" }\n" + |
1592 |
"}\n", // ================= |
1593 |
}, |
1594 |
""); |
1595 |
// ensure optimized boolean codegen sequence |
1596 |
String expectedOutput = |
1597 |
" public static void main(java.lang.String[] args);\n" + |
1598 |
" 0 return\n" + |
1599 |
" Line numbers:\n" + |
1600 |
" [pc: 0, line: 7]\n" + |
1601 |
" Local variable table:\n" + |
1602 |
" [pc: 0, pc: 1] local: args index: 0 type: java.lang.String[]\n"; |
1603 |
|
1604 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1605 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
1606 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
1607 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
1608 |
int index = result.indexOf(expectedOutput); |
1609 |
if (index == -1 || expectedOutput.length() == 0) { |
1610 |
System.out.println(Util.displayString(result, 3)); |
1611 |
} |
1612 |
if (index == -1) { |
1613 |
assertEquals("Wrong contents", expectedOutput, result); |
1614 |
} |
1615 |
} |
1509 |
public static Class testClass() { |
1616 |
public static Class testClass() { |
1510 |
return FlowAnalysisTest.class; |
1617 |
return FlowAnalysisTest.class; |
1511 |
} |
1618 |
} |