Bug 179159

Summary: Incorrect flagging of potential null pointer access
Product: [Eclipse Project] JDT Reporter: Darin Swanson <Darin_Swanson>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.3   
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Darin Swanson CLA 2007-03-24 14:23:30 EDT
3.3 M6

Code of the following form:
for (...) {
...
if (oldArgs == null && newArgs == null) {
	continue;
}
if(oldArgs.size() != newArgs.size()) {
	return true;
}
...
}
results in the compiler flaggin both the oldArgs.size and newArg.size as potential null pointer accesses.

Actually class in the Eclipse code base is BuilderPropertyPage within org.eclipse.ui.externaltools
Comment 1 Maxime Daniel CLA 2007-03-25 13:15:12 EDT
If any of oldArgs or newArgs is not null, then oldArgs.size() != newArgs.size() gets executed. Therefore if one of them is null and not the other, we get an NPE at runtime.
Contrast this with:
for (...) {
...
if (oldArgs == null || newArgs == null) {
        continue;
}
if(oldArgs.size() != newArgs.size()) {
        return true;
}
...
}
which must not (and does not) complain.

I believe there is no problem here.

I will read the complete test case tomorrow to see whether it has been oversimplified.
Comment 2 Darin Swanson CLA 2007-03-25 13:24:06 EDT
Sorry...you are entirely correct. There is no problem here.
Comment 3 Maxime Daniel CLA 2007-03-26 02:39:25 EDT
No problem. Closing as invalid.
Comment 4 Olivier Thomann CLA 2007-04-27 21:06:59 EDT
Verified for 3.3M7