Lines 14530-14533
Link Here
|
14530 |
"Dead code\n" + |
14530 |
"Dead code\n" + |
14531 |
"----------\n"); |
14531 |
"----------\n"); |
14532 |
} |
14532 |
} |
|
|
14533 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=342300 |
14534 |
public void testBug342300() throws Exception { |
14535 |
if (this.complianceLevel >= ClassFileConstants.JDK1_5) { |
14536 |
this.runConformTest( |
14537 |
new String[] { |
14538 |
"X.java", |
14539 |
"public class X {\n" + |
14540 |
" public static void initPattern(String p, Character escapeChar) {\n" + |
14541 |
" int len = p.length();\n" + |
14542 |
" for (int i = 0; i < len; i++) {\n" + |
14543 |
" char c = p.charAt(i);\n" + |
14544 |
" if (escapeChar != null && escapeChar == c) {\n" + // quiet |
14545 |
" c = p.charAt(++i);\n" + |
14546 |
" }\n" + |
14547 |
" }\n" + |
14548 |
" }\n" + |
14549 |
"}", |
14550 |
}, |
14551 |
""); |
14552 |
} |
14553 |
} |
14554 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=342300 |
14555 |
// To make sure only the redundant null check is given and not a potential NPE |
14556 |
public void testBug342300b() throws Exception { |
14557 |
if (this.complianceLevel >= ClassFileConstants.JDK1_5) { |
14558 |
this.runNegativeTest( |
14559 |
new String[] { |
14560 |
"X.java", |
14561 |
"public class X {\n" + |
14562 |
" public static void initPattern(String p, Character escapeChar) {\n" + |
14563 |
" int len = p.length();\n" + |
14564 |
" for (int i = 0; i < len; i++) {\n" + |
14565 |
" char c = p.charAt(i);\n" + |
14566 |
" if (escapeChar != null && escapeChar != null) {\n" + // look here |
14567 |
" c = p.charAt(++i);\n" + |
14568 |
" }\n" + |
14569 |
" }\n" + |
14570 |
" }\n" + |
14571 |
"}", |
14572 |
}, |
14573 |
"----------\n" + |
14574 |
"1. ERROR in X.java (at line 6)\n" + |
14575 |
" if (escapeChar != null && escapeChar != null) {\n" + |
14576 |
" ^^^^^^^^^^\n" + |
14577 |
"Redundant null check: The variable escapeChar cannot be null at this location\n" + |
14578 |
"----------\n"); |
14579 |
} |
14580 |
} |
14533 |
} |
14581 |
} |