Lines 10130-10133
Link Here
|
10130 |
"Potential null pointer access: The variable o1 may be null at this location\n" + |
10130 |
"Potential null pointer access: The variable o1 may be null at this location\n" + |
10131 |
"----------\n"); |
10131 |
"----------\n"); |
10132 |
} |
10132 |
} |
|
|
10133 |
|
10134 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418 |
10135 |
// Test to verify that redundant null checks are properly reported in all loops |
10136 |
public void testBug291418() { |
10137 |
if (this.complianceLevel >= ClassFileConstants.JDK1_5) { |
10138 |
this.runNegativeTest( |
10139 |
new String[] { |
10140 |
"X.java", |
10141 |
"class X {\n" + |
10142 |
" void foo(int[] argArray) {\n" + |
10143 |
" int[] array = {2};\n" + |
10144 |
" int[] collectionVar = {1,2};\n" + |
10145 |
" if(argArray == null) return;" + |
10146 |
" for(int x:collectionVar) {\n" + |
10147 |
" if (collectionVar == null);\n" + // collectionVar cannot be null here |
10148 |
" if (array == null);\n" + //array is not null here |
10149 |
" if (argArray == null);\n" + //argArray cannot be null here |
10150 |
" }\n" + |
10151 |
" int count = 0;\n" + |
10152 |
" do {\n" + |
10153 |
" count++;\n" + |
10154 |
" if (array == null);\n" + //array is not null here |
10155 |
" if (argArray == null);\n" + //argArray cannot be null here |
10156 |
" } while (count<10);\n" + |
10157 |
" for (int i=0; i<2; i++) {\n" + |
10158 |
" if (array == null);\n" + //array is not null here |
10159 |
" if (argArray == null);\n" + //argArray cannot be null here |
10160 |
" }\n" + |
10161 |
" while (true) {\n" + |
10162 |
" if (array == null);\n" + //array is not null here |
10163 |
" if (argArray == null);\n" + //argArray cannot be null here |
10164 |
" }\n" + |
10165 |
" }\n" + |
10166 |
"}"}, |
10167 |
"----------\n" + |
10168 |
"1. ERROR in X.java (at line 6)\n" + |
10169 |
" if (collectionVar == null);\n" + |
10170 |
" ^^^^^^^^^^^^^\n" + |
10171 |
"Null comparison always yields false: The variable collectionVar cannot be null at this location\n" + |
10172 |
"----------\n" + |
10173 |
"2. ERROR in X.java (at line 7)\n" + |
10174 |
" if (array == null);\n" + |
10175 |
" ^^^^^\n" + |
10176 |
"Null comparison always yields false: The variable array cannot be null at this location\n" + |
10177 |
"----------\n" + |
10178 |
"3. ERROR in X.java (at line 8)\n" + |
10179 |
" if (argArray == null);\n" + |
10180 |
" ^^^^^^^^\n" + |
10181 |
"Null comparison always yields false: The variable argArray cannot be null at this location\n" + |
10182 |
"----------\n" + |
10183 |
"4. ERROR in X.java (at line 13)\n" + |
10184 |
" if (array == null);\n" + |
10185 |
" ^^^^^\n" + |
10186 |
"Null comparison always yields false: The variable array cannot be null at this location\n" + |
10187 |
"----------\n" + |
10188 |
"5. ERROR in X.java (at line 14)\n" + |
10189 |
" if (argArray == null);\n" + |
10190 |
" ^^^^^^^^\n" + |
10191 |
"Null comparison always yields false: The variable argArray cannot be null at this location\n" + |
10192 |
"----------\n" + |
10193 |
"6. ERROR in X.java (at line 17)\n" + |
10194 |
" if (array == null);\n" + |
10195 |
" ^^^^^\n" + |
10196 |
"Null comparison always yields false: The variable array cannot be null at this location\n" + |
10197 |
"----------\n" + |
10198 |
"7. ERROR in X.java (at line 18)\n" + |
10199 |
" if (argArray == null);\n" + |
10200 |
" ^^^^^^^^\n" + |
10201 |
"Null comparison always yields false: The variable argArray cannot be null at this location\n" + |
10202 |
"----------\n" + |
10203 |
"8. ERROR in X.java (at line 21)\n" + |
10204 |
" if (array == null);\n" + |
10205 |
" ^^^^^\n" + |
10206 |
"Null comparison always yields false: The variable array cannot be null at this location\n" + |
10207 |
"----------\n" + |
10208 |
"9. ERROR in X.java (at line 22)\n" + |
10209 |
" if (argArray == null);\n" + |
10210 |
" ^^^^^^^^\n" + |
10211 |
"Null comparison always yields false: The variable argArray cannot be null at this location\n" + |
10212 |
"----------\n"); |
10213 |
} |
10214 |
} |
10133 |
} |
10215 |
} |