Lines 178-183
Link Here
|
178 |
" if (o != null) { /* */ }\n" + |
178 |
" if (o != null) { /* */ }\n" + |
179 |
" ^\n" + |
179 |
" ^\n" + |
180 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
180 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
|
|
181 |
"----------\n" + |
182 |
"2. WARNING in X.java (at line 4)\n" + |
183 |
" if (o != null) { /* */ }\n" + |
184 |
" ^^^^^^^^^\n" + |
185 |
"Dead code\n" + |
181 |
"----------\n", |
186 |
"----------\n", |
182 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
187 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
183 |
} |
188 |
} |
Lines 849-854
Link Here
|
849 |
" if (i == null) {};\n" + |
854 |
" if (i == null) {};\n" + |
850 |
" ^\n" + |
855 |
" ^\n" + |
851 |
"Null comparison always yields false: The variable i cannot be null at this location\n" + |
856 |
"Null comparison always yields false: The variable i cannot be null at this location\n" + |
|
|
857 |
"----------\n" + |
858 |
"2. WARNING in X.java (at line 4)\n" + |
859 |
" if (i == null) {};\n" + |
860 |
" ^^\n" + |
861 |
"Dead code\n" + |
852 |
"----------\n", |
862 |
"----------\n", |
853 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
863 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
854 |
} |
864 |
} |
Lines 911-916
Link Here
|
911 |
" if (i == null) {}\n" + |
921 |
" if (i == null) {}\n" + |
912 |
" ^\n" + |
922 |
" ^\n" + |
913 |
"Null comparison always yields false: The variable i cannot be null at this location\n" + |
923 |
"Null comparison always yields false: The variable i cannot be null at this location\n" + |
|
|
924 |
"----------\n" + |
925 |
"2. WARNING in X.java (at line 4)\n" + |
926 |
" if (i == null) {}\n" + |
927 |
" ^^\n" + |
928 |
"Dead code\n" + |
914 |
"----------\n", |
929 |
"----------\n", |
915 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
930 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
916 |
} |
931 |
} |
Lines 996-1001
Link Here
|
996 |
" if (o == null) {};\n" + |
1011 |
" if (o == null) {};\n" + |
997 |
" ^\n" + |
1012 |
" ^\n" + |
998 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1013 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1014 |
"----------\n" + |
1015 |
"2. WARNING in X.java (at line 4)\n" + |
1016 |
" if (o == null) {};\n" + |
1017 |
" ^^\n" + |
1018 |
"Dead code\n" + |
999 |
"----------\n", |
1019 |
"----------\n", |
1000 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1020 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1001 |
} |
1021 |
} |
Lines 1062-1067
Link Here
|
1062 |
" if (o == null) {/* empty */}\n" + |
1082 |
" if (o == null) {/* empty */}\n" + |
1063 |
" ^\n" + |
1083 |
" ^\n" + |
1064 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1084 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1085 |
"----------\n" + |
1086 |
"2. WARNING in X.java (at line 4)\n" + |
1087 |
" if (o == null) {/* empty */}\n" + |
1088 |
" ^^^^^^^^^^^^^\n" + |
1089 |
"Dead code\n" + |
1065 |
"----------\n", |
1090 |
"----------\n", |
1066 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1091 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1067 |
} |
1092 |
} |
Lines 1116-1121
Link Here
|
1116 |
" if (o == null) { /* */ }\n" + |
1141 |
" if (o == null) { /* */ }\n" + |
1117 |
" ^\n" + |
1142 |
" ^\n" + |
1118 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1143 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1144 |
"----------\n" + |
1145 |
"2. WARNING in X.java (at line 4)\n" + |
1146 |
" if (o == null) { /* */ }\n" + |
1147 |
" ^^^^^^^^^\n" + |
1148 |
"Dead code\n" + |
1119 |
"----------\n", |
1149 |
"----------\n", |
1120 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1150 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1121 |
} |
1151 |
} |
Lines 1153-1158
Link Here
|
1153 |
" if (c == null) {};\n" + |
1183 |
" if (c == null) {};\n" + |
1154 |
" ^\n" + |
1184 |
" ^\n" + |
1155 |
"Null comparison always yields false: The variable c cannot be null at this location\n" + |
1185 |
"Null comparison always yields false: The variable c cannot be null at this location\n" + |
|
|
1186 |
"----------\n" + |
1187 |
"2. WARNING in X.java (at line 4)\n" + |
1188 |
" if (c == null) {};\n" + |
1189 |
" ^^\n" + |
1190 |
"Dead code\n" + |
1156 |
"----------\n", |
1191 |
"----------\n", |
1157 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1192 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1158 |
} |
1193 |
} |
Lines 1216-1221
Link Here
|
1216 |
" if (o == null) { /* */ }\n" + |
1251 |
" if (o == null) { /* */ }\n" + |
1217 |
" ^\n" + |
1252 |
" ^\n" + |
1218 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1253 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1254 |
"----------\n" + |
1255 |
"3. WARNING in X.java (at line 6)\n" + |
1256 |
" if (o == null) { /* */ }\n" + |
1257 |
" ^^^^^^^^^\n" + |
1258 |
"Dead code\n" + |
1219 |
"----------\n", |
1259 |
"----------\n", |
1220 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1260 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1221 |
} |
1261 |
} |
Lines 1243-1248
Link Here
|
1243 |
" if (o == null) { /* */ }\n" + |
1283 |
" if (o == null) { /* */ }\n" + |
1244 |
" ^\n" + |
1284 |
" ^\n" + |
1245 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1285 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1286 |
"----------\n" + |
1287 |
"3. WARNING in X.java (at line 6)\n" + |
1288 |
" if (o == null) { /* */ }\n" + |
1289 |
" ^^^^^^^^^\n" + |
1290 |
"Dead code\n" + |
1246 |
"----------\n", |
1291 |
"----------\n", |
1247 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1292 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1248 |
} |
1293 |
} |
Lines 1415-1420
Link Here
|
1415 |
" if (x == null) { /* */ }\n" + |
1460 |
" if (x == null) { /* */ }\n" + |
1416 |
" ^\n" + |
1461 |
" ^\n" + |
1417 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
1462 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
|
|
1463 |
"----------\n" + |
1464 |
"2. WARNING in X.java (at line 4)\n" + |
1465 |
" if (x == null) { /* */ }\n" + |
1466 |
" ^^^^^^^^^\n" + |
1467 |
"Dead code\n" + |
1418 |
"----------\n", |
1468 |
"----------\n", |
1419 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1469 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1420 |
} |
1470 |
} |
Lines 1776-1781
Link Here
|
1776 |
" if (o == null) {\n" + |
1826 |
" if (o == null) {\n" + |
1777 |
" ^\n" + |
1827 |
" ^\n" + |
1778 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1828 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
1829 |
"----------\n" + |
1830 |
"2. WARNING in X.java (at line 4)\n" + |
1831 |
" if (o == null) {\n" + |
1832 |
" // do nothing\n" + |
1833 |
" }\n" + |
1834 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
1835 |
"Dead code\n" + |
1779 |
"----------\n", |
1836 |
"----------\n", |
1780 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1837 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1781 |
} |
1838 |
} |
Lines 1918-1927
Link Here
|
1918 |
" ^\n" + |
1975 |
" ^\n" + |
1919 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1976 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
1920 |
"----------\n" + |
1977 |
"----------\n" + |
1921 |
"2. ERROR in X.java (at line 7)\n" + |
1978 |
"2. WARNING in X.java (at line 5)\n" + |
1922 |
" o.toString();\n" + |
1979 |
" if (o == null) { /* */ }\n" + |
1923 |
" ^\n" + |
1980 |
" ^^^^^^^^^\n" + |
1924 |
"Potential null pointer access: The variable o may be null at this location\n" + |
1981 |
"Dead code\n" + |
|
|
1982 |
"----------\n" + |
1983 |
"3. ERROR in X.java (at line 6)\n" + |
1984 |
" if (o != null) { /* */ }\n" + |
1985 |
" ^\n" + |
1986 |
"Redundant null check: The variable o cannot be null at this location\n" + |
1925 |
"----------\n", |
1987 |
"----------\n", |
1926 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1988 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1927 |
} |
1989 |
} |
Lines 1945-1950
Link Here
|
1945 |
" if (o == null) { /* */ }\n" + |
2007 |
" if (o == null) { /* */ }\n" + |
1946 |
" ^\n" + |
2008 |
" ^\n" + |
1947 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
2009 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
2010 |
"----------\n" + |
2011 |
"2. WARNING in X.java (at line 6)\n" + |
2012 |
" if (o == null) { /* */ }\n" + |
2013 |
" ^^^^^^^^^\n" + |
2014 |
"Dead code\n" + |
1948 |
"----------\n", |
2015 |
"----------\n", |
1949 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2016 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
1950 |
} |
2017 |
} |
Lines 2083-2088
Link Here
|
2083 |
" if (o == null) { /* */ }\n" + |
2150 |
" if (o == null) { /* */ }\n" + |
2084 |
" ^\n" + |
2151 |
" ^\n" + |
2085 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
2152 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
2153 |
"----------\n" + |
2154 |
"2. WARNING in X.java (at line 4)\n" + |
2155 |
" if (o == null) { /* */ }\n" + |
2156 |
" ^^^^^^^^^\n" + |
2157 |
"Dead code\n" + |
2086 |
"----------\n", |
2158 |
"----------\n", |
2087 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2159 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2088 |
} |
2160 |
} |
Lines 2121-2126
Link Here
|
2121 |
" if (o == null) { /* */ }\n" + |
2193 |
" if (o == null) { /* */ }\n" + |
2122 |
" ^\n" + |
2194 |
" ^\n" + |
2123 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
2195 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
2196 |
"----------\n" + |
2197 |
"2. WARNING in X.java (at line 5)\n" + |
2198 |
" if (o == null) { /* */ }\n" + |
2199 |
" ^^^^^^^^^\n" + |
2200 |
"Dead code\n" + |
2124 |
"----------\n", |
2201 |
"----------\n", |
2125 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2202 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2126 |
} |
2203 |
} |
Lines 2402-2408
Link Here
|
2402 |
" o.toString();\n" + |
2479 |
" o.toString();\n" + |
2403 |
" }\n" + |
2480 |
" }\n" + |
2404 |
" else {\n" + |
2481 |
" else {\n" + |
2405 |
" o.toString();\n" + // must complain anyway (could be quite distant from the if test) |
2482 |
" o.toString();\n" + |
2406 |
" }\n" + |
2483 |
" }\n" + |
2407 |
" o.toString();\n" + // quiet |
2484 |
" o.toString();\n" + // quiet |
2408 |
" }\n" + |
2485 |
" }\n" + |
Lines 2413-2431
Link Here
|
2413 |
" ^\n" + |
2490 |
" ^\n" + |
2414 |
"Redundant null check: The variable o cannot be null at this location\n" + |
2491 |
"Redundant null check: The variable o cannot be null at this location\n" + |
2415 |
"----------\n" + |
2492 |
"----------\n" + |
2416 |
"2. ERROR in X.java (at line 8)\n" + |
2493 |
"2. WARNING in X.java (at line 7)\n" + |
2417 |
" o.toString();\n" + |
2494 |
" else {\n" + |
2418 |
" ^\n" + |
2495 |
" o.toString();\n" + |
2419 |
"Null pointer access: The variable o can only be null at this location\n" + |
2496 |
" }\n" + |
|
|
2497 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
2498 |
"Dead code\n" + |
2420 |
"----------\n", |
2499 |
"----------\n", |
2421 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2500 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2422 |
} |
2501 |
} |
2423 |
|
2502 |
|
2424 |
// null analysis - if/else |
2503 |
// null analysis - if/else |
2425 |
// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=129581 |
2504 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129581 |
2426 |
// this is a limit of the fix for bug 128014 - calls for a nuance |
2505 |
// Test that no false null reference warning is issued for a variable |
2427 |
// between potential null and tainted null |
2506 |
// that has been wrongly tainted by a redundant null check upstream. |
2428 |
public void _test0335_if_else() { |
2507 |
public void test0335_if_else() { |
2429 |
this.runNegativeTest( |
2508 |
this.runNegativeTest( |
2430 |
new String[] { |
2509 |
new String[] { |
2431 |
"X.java", |
2510 |
"X.java", |
Lines 2473-2482
Link Here
|
2473 |
" ^\n" + |
2552 |
" ^\n" + |
2474 |
"Redundant null check: The variable o cannot be null at this location\n" + |
2553 |
"Redundant null check: The variable o cannot be null at this location\n" + |
2475 |
"----------\n" + |
2554 |
"----------\n" + |
2476 |
"2. ERROR in X.java (at line 8)\n" + |
2555 |
"2. WARNING in X.java (at line 7)\n" + |
2477 |
" o.toString();\n" + |
2556 |
" else {\n" + |
2478 |
" ^\n" + |
2557 |
" o.toString();\n" + |
2479 |
"Null pointer access: The variable o can only be null at this location\n" + |
2558 |
" }\n" + |
|
|
2559 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
2560 |
"Dead code\n" + |
2480 |
"----------\n", |
2561 |
"----------\n", |
2481 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2562 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
2482 |
} |
2563 |
} |
Lines 3147-3152
Link Here
|
3147 |
" if (o == null) { /* */ }\n" + |
3228 |
" if (o == null) { /* */ }\n" + |
3148 |
" ^\n" + |
3229 |
" ^\n" + |
3149 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
3230 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
3231 |
"----------\n" + |
3232 |
"2. WARNING in X.java (at line 7)\n" + |
3233 |
" if (o == null) { /* */ }\n" + |
3234 |
" ^^^^^^^^^\n" + |
3235 |
"Dead code\n" + |
3150 |
"----------\n", |
3236 |
"----------\n", |
3151 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3237 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3152 |
} |
3238 |
} |
Lines 3172-3177
Link Here
|
3172 |
" if (o == null) { /* */ }\n" + |
3258 |
" if (o == null) { /* */ }\n" + |
3173 |
" ^\n" + |
3259 |
" ^\n" + |
3174 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
3260 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
3261 |
"----------\n" + |
3262 |
"2. WARNING in X.java (at line 7)\n" + |
3263 |
" if (o == null) { /* */ }\n" + |
3264 |
" ^^^^^^^^^\n" + |
3265 |
"Dead code\n" + |
3175 |
"----------\n", |
3266 |
"----------\n", |
3176 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3267 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3177 |
} |
3268 |
} |
Lines 3241-3246
Link Here
|
3241 |
" if (o == null) { /* */ }\n" + |
3332 |
" if (o == null) { /* */ }\n" + |
3242 |
" ^\n" + |
3333 |
" ^\n" + |
3243 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
3334 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
3335 |
"----------\n" + |
3336 |
"2. WARNING in X.java (at line 6)\n" + |
3337 |
" if (o == null) { /* */ }\n" + |
3338 |
" ^^^^^^^^^\n" + |
3339 |
"Dead code\n" + |
3244 |
"----------\n", |
3340 |
"----------\n", |
3245 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3341 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
3246 |
} |
3342 |
} |
Lines 4492-4497
Link Here
|
4492 |
" if (o == null) { /* */ }\n" + |
4588 |
" if (o == null) { /* */ }\n" + |
4493 |
" ^\n" + |
4589 |
" ^\n" + |
4494 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
4590 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
4591 |
"----------\n" + |
4592 |
"2. WARNING in X.java (at line 7)\n" + |
4593 |
" if (o == null) { /* */ }\n" + |
4594 |
" ^^^^^^^^^\n" + |
4595 |
"Dead code\n" + |
4495 |
"----------\n", |
4596 |
"----------\n", |
4496 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
4597 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
4497 |
} |
4598 |
} |
Lines 4517-4522
Link Here
|
4517 |
" if (o == null) {\n" + |
4618 |
" if (o == null) {\n" + |
4518 |
" ^\n" + |
4619 |
" ^\n" + |
4519 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
4620 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
4621 |
"----------\n" + |
4622 |
"2. WARNING in X.java (at line 7)\n" + |
4623 |
" if (o == null) {\n" + |
4624 |
" o = new Object();\n" + |
4625 |
" }\n" + |
4626 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
4627 |
"Dead code\n" + |
4520 |
"----------\n", |
4628 |
"----------\n", |
4521 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
4629 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
4522 |
} |
4630 |
} |
Lines 5810-5815
Link Here
|
5810 |
" if (ex == null) {\n" + |
5918 |
" if (ex == null) {\n" + |
5811 |
" ^^\n" + |
5919 |
" ^^\n" + |
5812 |
"Null comparison always yields false: The variable ex cannot be null at this location\n" + |
5920 |
"Null comparison always yields false: The variable ex cannot be null at this location\n" + |
|
|
5921 |
"----------\n" + |
5922 |
"2. WARNING in X.java (at line 20)\n" + |
5923 |
" if (ex == null) {\n" + |
5924 |
" }\n" + |
5925 |
" ^^^^^^^\n" + |
5926 |
"Dead code\n" + |
5813 |
"----------\n", |
5927 |
"----------\n", |
5814 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
5928 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
5815 |
} |
5929 |
} |
Lines 7587-7592
Link Here
|
7587 |
" if(o == null) { /* */ }\n" + |
7701 |
" if(o == null) { /* */ }\n" + |
7588 |
" ^\n" + |
7702 |
" ^\n" + |
7589 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
7703 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
7704 |
"----------\n" + |
7705 |
"2. WARNING in X.java (at line 12)\n" + |
7706 |
" if(o == null) { /* */ }\n" + |
7707 |
" ^^^^^^^^^\n" + |
7708 |
"Dead code\n" + |
7590 |
"----------\n", |
7709 |
"----------\n", |
7591 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
7710 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
7592 |
} |
7711 |
} |
Lines 7962-7968
Link Here
|
7962 |
" ^^\n" + |
8081 |
" ^^\n" + |
7963 |
"Null comparison always yields false: The variable o1 cannot be null at this location\n" + |
8082 |
"Null comparison always yields false: The variable o1 cannot be null at this location\n" + |
7964 |
"----------\n" + |
8083 |
"----------\n" + |
7965 |
"2. ERROR in X.java (at line 5)\n" + |
8084 |
"2. WARNING in X.java (at line 4)\n" + |
|
|
8085 |
" if (o1 == null) { };\n" + |
8086 |
" ^^^\n" + |
8087 |
"Dead code\n" + |
8088 |
"----------\n" + |
8089 |
"3. ERROR in X.java (at line 5)\n" + |
7966 |
" if (o2 == null) { };\n" + |
8090 |
" if (o2 == null) { };\n" + |
7967 |
" ^^\n" + |
8091 |
" ^^\n" + |
7968 |
"Redundant null check: The variable o2 can only be null at this location\n" + |
8092 |
"Redundant null check: The variable o2 can only be null at this location\n" + |
Lines 8011-8016
Link Here
|
8011 |
" if (o == null) { };\n" + |
8135 |
" if (o == null) { };\n" + |
8012 |
" ^\n" + |
8136 |
" ^\n" + |
8013 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
8137 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
8138 |
"----------\n" + |
8139 |
"2. WARNING in X.java (at line 4)\n" + |
8140 |
" if (o == null) { };\n" + |
8141 |
" ^^^\n" + |
8142 |
"Dead code\n" + |
8014 |
"----------\n", |
8143 |
"----------\n", |
8015 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8144 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8016 |
} |
8145 |
} |
Lines 8040-8045
Link Here
|
8040 |
" if (o == null) { };\n" + |
8169 |
" if (o == null) { };\n" + |
8041 |
" ^\n" + |
8170 |
" ^\n" + |
8042 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
8171 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
8172 |
"----------\n" + |
8173 |
"3. WARNING in X.java (at line 5)\n" + |
8174 |
" if (o == null) { };\n" + |
8175 |
" ^^^\n" + |
8176 |
"Dead code\n" + |
8043 |
"----------\n", |
8177 |
"----------\n", |
8044 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8178 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8045 |
} |
8179 |
} |
Lines 8208-8227
Link Here
|
8208 |
" ^\n" + |
8342 |
" ^\n" + |
8209 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
8343 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
8210 |
"----------\n" + |
8344 |
"----------\n" + |
8211 |
"3. ERROR in X.java (at line 6)\n" + |
8345 |
"3. WARNING in X.java (at line 5)\n" + |
8212 |
" x.foo(null); // 3\n" + |
8346 |
" if (x == null) { // 2\n" + |
8213 |
" ^\n" + |
8347 |
" x.foo(null); // 3\n" + |
8214 |
"Null pointer access: The variable x can only be null at this location\n" + |
8348 |
" } else if (x instanceof X) { // 4\n" + |
|
|
8349 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
8350 |
"Dead code\n" + |
8215 |
"----------\n" + |
8351 |
"----------\n" + |
8216 |
"4. ERROR in X.java (at line 9)\n" + |
8352 |
"4. ERROR in X.java (at line 9)\n" + |
8217 |
" } else if (x != null) { // 6\n" + |
8353 |
" } else if (x != null) { // 6\n" + |
8218 |
" ^\n" + |
8354 |
" ^\n" + |
8219 |
"Redundant null check: The variable x cannot be null at this location\n" + |
8355 |
"Redundant null check: The variable x cannot be null at this location\n" + |
8220 |
"----------\n" + |
|
|
8221 |
"5. ERROR in X.java (at line 12)\n" + |
8222 |
" x.foo(null); // 8\n" + |
8223 |
" ^\n" + |
8224 |
"Potential null pointer access: The variable x may be null at this location\n" + |
8225 |
"----------\n", |
8356 |
"----------\n", |
8226 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8357 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8227 |
} |
8358 |
} |
Lines 8375-8380
Link Here
|
8375 |
" if (other != null) {\n" + |
8506 |
" if (other != null) {\n" + |
8376 |
" ^^^^^\n" + |
8507 |
" ^^^^^\n" + |
8377 |
"Redundant null check: The variable other cannot be null at this location\n" + |
8508 |
"Redundant null check: The variable other cannot be null at this location\n" + |
|
|
8509 |
"----------\n" + |
8510 |
"2. ERROR in X.java (at line 11)\n" + |
8511 |
" if (other == null) {\n" + |
8512 |
" ^^^^^\n" + |
8513 |
"Null comparison always yields false: The variable other cannot be null at this location\n" + |
8514 |
"----------\n" + |
8515 |
"3. WARNING in X.java (at line 11)\n" + |
8516 |
" if (other == null) {\n" + |
8517 |
" }\n" + |
8518 |
" ^^^^^^^^^\n" + |
8519 |
"Dead code\n" + |
8378 |
"----------\n", |
8520 |
"----------\n", |
8379 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8521 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8380 |
} |
8522 |
} |
Lines 8428-8437
Link Here
|
8428 |
" ^\n" + |
8570 |
" ^\n" + |
8429 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
8571 |
"Null comparison always yields false: The variable x cannot be null at this location\n" + |
8430 |
"----------\n" + |
8572 |
"----------\n" + |
8431 |
"2. ERROR in X.java (at line 5)\n" + |
8573 |
"2. WARNING in X.java (at line 4)\n" + |
8432 |
" x.foo(this);\n" + |
8574 |
" if (x == null) {\n" + |
8433 |
" ^\n" + |
8575 |
" x.foo(this);\n" + |
8434 |
"Null pointer access: The variable x can only be null at this location\n" + |
8576 |
" }\n" + |
|
|
8577 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
8578 |
"Dead code\n" + |
8435 |
"----------\n", |
8579 |
"----------\n", |
8436 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8580 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8437 |
} |
8581 |
} |
Lines 8680-8685
Link Here
|
8680 |
" if (o == null) return;\n" + |
8824 |
" if (o == null) return;\n" + |
8681 |
" ^\n" + |
8825 |
" ^\n" + |
8682 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
8826 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
8827 |
"----------\n" + |
8828 |
"2. WARNING in X.java (at line 13)\n" + |
8829 |
" if (o == null) return;\n" + |
8830 |
" ^^^^^^^\n" + |
8831 |
"Dead code\n" + |
8683 |
"----------\n", |
8832 |
"----------\n", |
8684 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8833 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8685 |
} |
8834 |
} |
Lines 8739-8744
Link Here
|
8739 |
" if (o == null) return;\n" + |
8888 |
" if (o == null) return;\n" + |
8740 |
" ^\n" + |
8889 |
" ^\n" + |
8741 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
8890 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
8891 |
"----------\n" + |
8892 |
"2. WARNING in X.java (at line 10)\n" + |
8893 |
" if (o == null) return;\n" + |
8894 |
" ^^^^^^^\n" + |
8895 |
"Dead code\n" + |
8742 |
"----------\n", |
8896 |
"----------\n", |
8743 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8897 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8744 |
} |
8898 |
} |
Lines 8890-8895
Link Here
|
8890 |
" if (a == null) {\n" + |
9044 |
" if (a == null) {\n" + |
8891 |
" ^\n" + |
9045 |
" ^\n" + |
8892 |
"Null comparison always yields false: The variable a cannot be null at this location\n" + |
9046 |
"Null comparison always yields false: The variable a cannot be null at this location\n" + |
|
|
9047 |
"----------\n" + |
9048 |
"3. WARNING in X.java (at line 13)\n" + |
9049 |
" if (a == null) {\n" + |
9050 |
" System.out.println();\n" + |
9051 |
" }\n" + |
9052 |
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9053 |
"Dead code\n" + |
8893 |
"----------\n", |
9054 |
"----------\n", |
8894 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9055 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8895 |
} |
9056 |
} |
Lines 8947-8952
Link Here
|
8947 |
" if(a!=null)\n" + |
9108 |
" if(a!=null)\n" + |
8948 |
" ^\n" + |
9109 |
" ^\n" + |
8949 |
"Null comparison always yields false: The variable a can only be null at this location\n" + |
9110 |
"Null comparison always yields false: The variable a can only be null at this location\n" + |
|
|
9111 |
"----------\n" + |
9112 |
"3. WARNING in X.java (at line 9)\n" + |
9113 |
" { /* */ }\n" + |
9114 |
" ^^^^^^^^^\n" + |
9115 |
"Dead code\n" + |
8950 |
"----------\n", |
9116 |
"----------\n", |
8951 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9117 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
8952 |
} |
9118 |
} |
Lines 9043-9049
Link Here
|
9043 |
"}\n" |
9209 |
"}\n" |
9044 |
} /* testFiles */, |
9210 |
} /* testFiles */, |
9045 |
"----------\n" + |
9211 |
"----------\n" + |
9046 |
"1. WARNING in X.java (at line 8)\n" + |
9212 |
"1. WARNING in X.java (at line 4)\n" + |
|
|
9213 |
" if (o != null) {\n" + |
9214 |
" o = null;\n" + |
9215 |
" }\n" + |
9216 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9217 |
"Dead code\n" + |
9218 |
"----------\n" + |
9219 |
"2. WARNING in X.java (at line 8)\n" + |
9047 |
" o.toString();\n" + |
9220 |
" o.toString();\n" + |
9048 |
" ^\n" + |
9221 |
" ^\n" + |
9049 |
"Null pointer access: The variable o can only be null at this location\n" + |
9222 |
"Null pointer access: The variable o can only be null at this location\n" + |
Lines 9105-9122
Link Here
|
9105 |
" }\n" + |
9278 |
" }\n" + |
9106 |
"}\n"}, |
9279 |
"}\n"}, |
9107 |
"----------\n" + |
9280 |
"----------\n" + |
9108 |
"1. ERROR in X.java (at line 4)\r\n" + |
9281 |
"1. ERROR in X.java (at line 4)\n" + |
9109 |
" if (o != null) {\r\n" + |
9282 |
" if (o != null) {\n" + |
9110 |
" ^\n" + |
9283 |
" ^\n" + |
9111 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9284 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9112 |
"----------\n" + |
9285 |
"----------\n" + |
9113 |
"2. ERROR in X.java (at line 8)\r\n" + |
9286 |
"2. WARNING in X.java (at line 4)\n" + |
9114 |
" o.toString();\r\n" + |
9287 |
" if (o != null) {\n" + |
|
|
9288 |
" o = null;\n" + |
9289 |
" }\n" + |
9290 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9291 |
"Dead code\n" + |
9292 |
"----------\n" + |
9293 |
"3. ERROR in X.java (at line 8)\n" + |
9294 |
" o.toString();\n" + |
9115 |
" ^\n" + |
9295 |
" ^\n" + |
9116 |
"Null pointer access: The variable o can only be null at this location\n" + |
9296 |
"Null pointer access: The variable o can only be null at this location\n" + |
9117 |
"----------\n" + |
9297 |
"----------\n" + |
9118 |
"3. ERROR in X.java (at line 9)\r\n" + |
9298 |
"4. ERROR in X.java (at line 9)\n" + |
9119 |
" p.toString();\r\n" + |
9299 |
" p.toString();\n" + |
9120 |
" ^\n" + |
9300 |
" ^\n" + |
9121 |
"Potential null pointer access: The variable p may be null at this location\n" + |
9301 |
"Potential null pointer access: The variable p may be null at this location\n" + |
9122 |
"----------\n", |
9302 |
"----------\n", |
Lines 9152-9159
Link Here
|
9152 |
customOptions /* custom options */, |
9332 |
customOptions /* custom options */, |
9153 |
// compiler results |
9333 |
// compiler results |
9154 |
"----------\n" + /* expected compiler log */ |
9334 |
"----------\n" + /* expected compiler log */ |
9155 |
"1. ERROR in X.java (at line 8)\r\n" + |
9335 |
"1. WARNING in X.java (at line 4)\n" + |
9156 |
" o.toString();\r\n" + |
9336 |
" if (o != null) {\n" + |
|
|
9337 |
" o = null;\n" + |
9338 |
" }\n" + |
9339 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9340 |
"Dead code\n" + |
9341 |
"----------\n" + |
9342 |
"2. ERROR in X.java (at line 8)\n" + |
9343 |
" o.toString();\n" + |
9157 |
" ^\n" + |
9344 |
" ^\n" + |
9158 |
"Null pointer access: The variable o can only be null at this location\n" + |
9345 |
"Null pointer access: The variable o can only be null at this location\n" + |
9159 |
"----------\n", |
9346 |
"----------\n", |
Lines 9190-9202
Link Here
|
9190 |
customOptions /* custom options */, |
9377 |
customOptions /* custom options */, |
9191 |
// compiler results |
9378 |
// compiler results |
9192 |
"----------\n" + /* expected compiler log */ |
9379 |
"----------\n" + /* expected compiler log */ |
9193 |
"1. ERROR in X.java (at line 4)\r\n" + |
9380 |
"1. ERROR in X.java (at line 4)\n" + |
9194 |
" if (o != null) {\r\n" + |
9381 |
" if (o != null) {\n" + |
9195 |
" ^\n" + |
9382 |
" ^\n" + |
9196 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9383 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9197 |
"----------\n" + |
9384 |
"----------\n" + |
9198 |
"2. WARNING in X.java (at line 8)\r\n" + |
9385 |
"2. WARNING in X.java (at line 4)\n" + |
9199 |
" o.toString();\r\n" + |
9386 |
" if (o != null) {\n" + |
|
|
9387 |
" o = null;\n" + |
9388 |
" }\n" + |
9389 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9390 |
"Dead code\n" + |
9391 |
"----------\n" + |
9392 |
"3. WARNING in X.java (at line 8)\n" + |
9393 |
" o.toString();\n" + |
9200 |
" ^\n" + |
9394 |
" ^\n" + |
9201 |
"Null pointer access: The variable o can only be null at this location\n" + |
9395 |
"Null pointer access: The variable o can only be null at this location\n" + |
9202 |
"----------\n", |
9396 |
"----------\n", |
Lines 9233-9245
Link Here
|
9233 |
customOptions /* custom options */, |
9427 |
customOptions /* custom options */, |
9234 |
// compiler results |
9428 |
// compiler results |
9235 |
"----------\n" + /* expected compiler log */ |
9429 |
"----------\n" + /* expected compiler log */ |
9236 |
"1. ERROR in X.java (at line 4)\r\n" + |
9430 |
"1. ERROR in X.java (at line 4)\n" + |
9237 |
" if (o != null) {\r\n" + |
9431 |
" if (o != null) {\n" + |
9238 |
" ^\n" + |
9432 |
" ^\n" + |
9239 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9433 |
"Null comparison always yields false: The variable o can only be null at this location\n" + |
9240 |
"----------\n" + |
9434 |
"----------\n" + |
9241 |
"2. ERROR in X.java (at line 9)\r\n" + |
9435 |
"2. WARNING in X.java (at line 4)\n" + |
9242 |
" p.toString();\r\n" + |
9436 |
" if (o != null) {\n" + |
|
|
9437 |
" o = null;\n" + |
9438 |
" }\n" + |
9439 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9440 |
"Dead code\n" + |
9441 |
"----------\n" + |
9442 |
"3. ERROR in X.java (at line 9)\n" + |
9443 |
" p.toString();\n" + |
9243 |
" ^\n" + |
9444 |
" ^\n" + |
9244 |
"Potential null pointer access: The variable p may be null at this location\n" + |
9445 |
"Potential null pointer access: The variable p may be null at this location\n" + |
9245 |
"----------\n", |
9446 |
"----------\n", |
Lines 9278-9285
Link Here
|
9278 |
customOptions /* custom options */, |
9479 |
customOptions /* custom options */, |
9279 |
// compiler results |
9480 |
// compiler results |
9280 |
"----------\n" + /* expected compiler log */ |
9481 |
"----------\n" + /* expected compiler log */ |
9281 |
"1. ERROR in X.java (at line 9)\r\n" + |
9482 |
"1. WARNING in X.java (at line 5)\n" + |
9282 |
" o.toString();\r\n" + |
9483 |
" if (o != null) {\n" + |
|
|
9484 |
" o = null;\n" + |
9485 |
" }\n" + |
9486 |
" ^^^^^^^^^^^^^^^^^^^^^^^^\n" + |
9487 |
"Dead code\n" + |
9488 |
"----------\n" + |
9489 |
"2. ERROR in X.java (at line 9)\n" + |
9490 |
" o.toString();\n" + |
9283 |
" ^\n" + |
9491 |
" ^\n" + |
9284 |
"Null pointer access: The variable o can only be null at this location\n" + |
9492 |
"Null pointer access: The variable o can only be null at this location\n" + |
9285 |
"----------\n", |
9493 |
"----------\n", |
Lines 9489-9494
Link Here
|
9489 |
" if (o65 == null) { /* */ }\n" + |
9697 |
" if (o65 == null) { /* */ }\n" + |
9490 |
" ^^^\n" + |
9698 |
" ^^^\n" + |
9491 |
"Null comparison always yields false: The variable o65 cannot be null at this location\n" + |
9699 |
"Null comparison always yields false: The variable o65 cannot be null at this location\n" + |
|
|
9700 |
"----------\n" + |
9701 |
"2. WARNING in X.java (at line 18)\n" + |
9702 |
" if (o65 == null) { /* */ }\n" + |
9703 |
" ^^^^^^^^^\n" + |
9704 |
"Dead code\n" + |
9705 |
"----------\n" + |
9706 |
"3. ERROR in X.java (at line 19)\n" + |
9707 |
" if (o65 != null) { /* */ }\n" + |
9708 |
" ^^^\n" + |
9709 |
"Redundant null check: The variable o65 cannot be null at this location\n" + |
9492 |
"----------\n", |
9710 |
"----------\n", |
9493 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9711 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9494 |
} |
9712 |
} |
Lines 9746-9751
Link Here
|
9746 |
" if (o == null) { /* */ }\n" + |
9964 |
" if (o == null) { /* */ }\n" + |
9747 |
" ^\n" + |
9965 |
" ^\n" + |
9748 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
9966 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
9967 |
"----------\n" + |
9968 |
"2. WARNING in X.java (at line 20)\n" + |
9969 |
" if (o == null) { /* */ }\n" + |
9970 |
" ^^^^^^^^^\n" + |
9971 |
"Dead code\n" + |
9749 |
"----------\n", |
9972 |
"----------\n", |
9750 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9973 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9751 |
} |
9974 |
} |
Lines 9783-9788
Link Here
|
9783 |
" if (o == null) { /* */ }\n" + |
10006 |
" if (o == null) { /* */ }\n" + |
9784 |
" ^\n" + |
10007 |
" ^\n" + |
9785 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
10008 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
10009 |
"----------\n" + |
10010 |
"2. WARNING in X.java (at line 21)\n" + |
10011 |
" if (o == null) { /* */ }\n" + |
10012 |
" ^^^^^^^^^\n" + |
10013 |
"Dead code\n" + |
9786 |
"----------\n", |
10014 |
"----------\n", |
9787 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10015 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9788 |
} |
10016 |
} |
Lines 9823-9828
Link Here
|
9823 |
" if (o == null) { /* */ }\n" + |
10051 |
" if (o == null) { /* */ }\n" + |
9824 |
" ^\n" + |
10052 |
" ^\n" + |
9825 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
10053 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
10054 |
"----------\n" + |
10055 |
"2. WARNING in X.java (at line 24)\n" + |
10056 |
" if (o == null) { /* */ }\n" + |
10057 |
" ^^^^^^^^^\n" + |
10058 |
"Dead code\n" + |
9826 |
"----------\n", |
10059 |
"----------\n", |
9827 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10060 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9828 |
} |
10061 |
} |
Lines 9863-9868
Link Here
|
9863 |
" if (o == null) { /* */ }\n" + |
10096 |
" if (o == null) { /* */ }\n" + |
9864 |
" ^\n" + |
10097 |
" ^\n" + |
9865 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
10098 |
"Null comparison always yields false: The variable o cannot be null at this location\n" + |
|
|
10099 |
"----------\n" + |
10100 |
"2. WARNING in X.java (at line 24)\n" + |
10101 |
" if (o == null) { /* */ }\n" + |
10102 |
" ^^^^^^^^^\n" + |
10103 |
"Dead code\n" + |
9866 |
"----------\n", |
10104 |
"----------\n", |
9867 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10105 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
9868 |
} |
10106 |
} |
Lines 10328-10331
Link Here
|
10328 |
"----------\n"); |
10566 |
"----------\n"); |
10329 |
} |
10567 |
} |
10330 |
} |
10568 |
} |
|
|
10569 |
|
10570 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=293917 |
10571 |
// Test that a redundant null check doesn't affect the null status of |
10572 |
// a variable downstream. |
10573 |
public void testBug293917() { |
10574 |
this.runNegativeTest( |
10575 |
new String[] { |
10576 |
"X.java", |
10577 |
"public class X {\n" + |
10578 |
" public void foo(){\n" + |
10579 |
" String x = null, y = null;\n" + |
10580 |
" if (x == null) x = \"foo\";\n" + |
10581 |
" if (x != null) y = \"bar\";\n" + |
10582 |
" x.length();\n" + // shouldn't warn here |
10583 |
" y.length();\n" + // shouldn't warn here |
10584 |
" }\n" + |
10585 |
"}\n"}, |
10586 |
"----------\n" + |
10587 |
"1. ERROR in X.java (at line 4)\n" + |
10588 |
" if (x == null) x = \"foo\";\n" + |
10589 |
" ^\n" + |
10590 |
"Redundant null check: The variable x can only be null at this location\n" + |
10591 |
"----------\n" + |
10592 |
"2. ERROR in X.java (at line 5)\n" + |
10593 |
" if (x != null) y = \"bar\";\n" + |
10594 |
" ^\n" + |
10595 |
"Redundant null check: The variable x cannot be null at this location\n" + |
10596 |
"----------\n", |
10597 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10598 |
} |
10599 |
|
10600 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=190623 |
10601 |
//Test that a redundant null check doesn't affect the null status of |
10602 |
//a variable downstream. |
10603 |
public void testBug190623() { |
10604 |
this.runNegativeTest( |
10605 |
new String[] { |
10606 |
"X.java", |
10607 |
"public class X {\n" + |
10608 |
" public static void main(String[] args) {\n" + |
10609 |
" Number n = getNumber();\n" + |
10610 |
" if (n instanceof Double) {\n" + |
10611 |
" Double d= (Double) n;\n" + |
10612 |
" if (d != null && d.isNaN()) {\n" + |
10613 |
" System.out.println(\"outside loop\");\n" + |
10614 |
" }\n" + |
10615 |
" for (int i= 0; i < 10; i++) {\n" + |
10616 |
" if (d != null && d.isNaN()) {\n" + |
10617 |
" System.out.println(\"inside loop\");\n" + |
10618 |
" }\n" + |
10619 |
" }\n" + |
10620 |
" }\n" + |
10621 |
" }\n" + |
10622 |
" private static Number getNumber() {\n" + |
10623 |
" return new Double(Math.sqrt(-1));\n" + |
10624 |
" }\n" + |
10625 |
"}\n"}, |
10626 |
"----------\n" + |
10627 |
"1. ERROR in X.java (at line 6)\n" + |
10628 |
" if (d != null && d.isNaN()) {\n" + |
10629 |
" ^\n" + |
10630 |
"Redundant null check: The variable d cannot be null at this location\n" + |
10631 |
"----------\n" + |
10632 |
"2. ERROR in X.java (at line 10)\n" + |
10633 |
" if (d != null && d.isNaN()) {\n" + |
10634 |
" ^\n" + |
10635 |
"Redundant null check: The variable d cannot be null at this location\n" + |
10636 |
"----------\n", |
10637 |
JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); |
10638 |
} |
10331 |
} |
10639 |
} |