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 10328-10331
Link Here
|
10328 |
"----------\n"); |
10328 |
"----------\n"); |
10329 |
} |
10329 |
} |
10330 |
} |
10330 |
} |
|
|
10331 |
|
10332 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900 |
10333 |
// Test to verify that null checks are properly reported for the variable(s) |
10334 |
// in the right expression of an OR condition statement. |
10335 |
public void testBug299900a() { |
10336 |
this.runNegativeTest( |
10337 |
new String[] { |
10338 |
"X.java", |
10339 |
"class X {\n" + |
10340 |
" void foo(Object foo, Object bar) {\n" + |
10341 |
" if(foo == null || bar == null) {\n" + |
10342 |
" System.out.println(foo.toString());\n" + |
10343 |
" System.out.println(bar.toString());\n" + |
10344 |
" }\n" + |
10345 |
" }\n" + |
10346 |
"}"}, |
10347 |
"----------\n" + |
10348 |
"1. ERROR in X.java (at line 4)\n" + |
10349 |
" System.out.println(foo.toString());\n" + |
10350 |
" ^^^\n" + |
10351 |
"Potential null pointer access: The variable foo may be null at this location\n" + |
10352 |
"----------\n" + |
10353 |
"2. ERROR in X.java (at line 5)\n" + |
10354 |
" System.out.println(bar.toString());\n" + |
10355 |
" ^^^\n" + |
10356 |
"Potential null pointer access: The variable bar may be null at this location\n" + |
10357 |
"----------\n"); |
10358 |
} |
10359 |
|
10360 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=299900 |
10361 |
// Test to verify that null checks are properly reported for the variable(s) |
10362 |
// in the right expression of an OR condition statement. |
10363 |
public void testBug299900b() { |
10364 |
this.runNegativeTest( |
10365 |
new String[] { |
10366 |
"X.java", |
10367 |
"class X {\n" + |
10368 |
" void foo(Object foo, Object bar) {\n" + |
10369 |
" if(foo == null || bar == null) {\n" + |
10370 |
" }\n" + |
10371 |
" System.out.println(foo.toString());\n" + |
10372 |
" System.out.println(bar.toString());\n" + |
10373 |
" }\n" + |
10374 |
"}"}, |
10375 |
"----------\n" + |
10376 |
"1. ERROR in X.java (at line 5)\n" + |
10377 |
" System.out.println(foo.toString());\n" + |
10378 |
" ^^^\n" + |
10379 |
"Potential null pointer access: The variable foo may be null at this location\n" + |
10380 |
"----------\n" + |
10381 |
"2. ERROR in X.java (at line 6)\n" + |
10382 |
" System.out.println(bar.toString());\n" + |
10383 |
" ^^^\n" + |
10384 |
"Potential null pointer access: The variable bar may be null at this location\n" + |
10385 |
"----------\n"); |
10386 |
} |
10331 |
} |
10387 |
} |