Community
Participate
Working Groups
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)
Sounds interesting. Will consider post 3.2.
Philippe, what do you think re. 3.3?
Reopening to link to bug 170704.
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 ***