This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 232001 - "Unnecessary test for null" is incorrect
Summary: "Unnecessary test for null" is incorrect
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-28 14:55 UTC by jbfaden
Modified: 2013-07-09 13:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jbfaden 2013-06-28 14:55:46 UTC
Product Version = NetBeans IDE 7.3 (Build 201302132200)
Operating System = Linux version 3.2.0-44-generic running on amd64
Java; VM; Vendor = 1.7.0_11
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.6-b04

The suggestion for "Unnecessary test for null" is incorrect.  I have something like:
public class NewClass {
    public static void main( String[] args ) {
        HashMap<String,String> m= new HashMap();
        String alpha= m.get("alpha");
        if ( alpha==null && m.containsKey("alphanumeric") ) {
            alpha= "T";
        }
        if ( alpha==null ) {
            System.err.println( "alpha is null" );
        }
    }
}

 and I'm getting the suggestion on the "alpha==null" test.
Comment 1 Jan Lahoda 2013-07-01 14:19:46 UTC
Appears to be fixed in the daily builds (likely also fixed in a 7.3 update). I don't have a specific bug number, though. Jirka, could you please double-check? Thanks.
Comment 2 Jiri Prox 2013-07-09 13:08:36 UTC
Verified in 7.3.1 and 7.4 beta