Bug 138009 - [compiler][null][enh] Add ability for setting severity level of different null-references problems
Summary: [compiler][null][enh] Add ability for setting severity level of different nul...
Status: RESOLVED DUPLICATE of bug 170704
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-21 13:22 EDT by x y CLA
Modified: 2007-01-30 04:18 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description x y CLA 2006-04-21 13:22:31 EDT
Most programmers would like to set 'Error' severity level for 1st case, but 'Warning' for 2nd & 3rd (or even ignore 3d).

1)
// The variable string can only be null; it was either set to null or checked for null when last used.
// This is DEFINITELY BAD code, since NPE would be thrown.
// Probably programmer meant: string != null && string.length() == 0
if (string == null && string.length() == 0)

2)
// The variable string may be null
// This is PROBABLY BAD code, since string can be null.
if (string.length() == 0)

3)        
// The variable string cannot be null; it was either set to a non-null value or assumed to be non-null when last used
// This is UNNEEDED CORRECT code, since string definitely cannot be null.
if (string != null && string.length() == 0)
Comment 1 Maxime Daniel CLA 2006-04-25 00:50:47 EDT
Sounds interesting. Will consider post 3.2.
Comment 2 Maxime Daniel CLA 2006-09-26 09:09:39 EDT
Philippe, what do you think re. 3.3?
Comment 3 Maxime Daniel CLA 2007-01-30 04:17:47 EST
Reopening to link to bug 170704.
Comment 4 Maxime Daniel CLA 2007-01-30 04:18:50 EST
This bug has been considered when tackling bug 170704. We expect to come up with a solution that will address the needs of this bug as well. Hence resolving as duplicate.

*** This bug has been marked as a duplicate of bug 170704 ***