Bug 179159 - Incorrect flagging of potential null pointer access
Summary: Incorrect flagging of potential null pointer access
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-24 14:23 EDT by Darin Swanson CLA
Modified: 2007-04-27 21:06 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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