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