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 153351

Summary: Null checks and redundant null checks.
Product: java Reporter: elberry <elberry>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description elberry 2008-11-18 01:23:36 UTC
One feature I miss from IntelliJ and Eclipse is the null pointer access and redundant null check warnings.

Example code:
[code]
public class Main {

    public static void main(String[] args) {
        String test = null;
        test.startsWith("oops");
        if(test != null) {
            test.endsWith("oops");
        }
    }

}
[/code]

In NetBeans this code produces no warnings. However in Eclipse, this code produces two warnings. The first points out
that "test" in "test.startsWith("oops");" is accessing a null object and thus shows a warning about a looming nullpointer. 

The second points out "test" in "if(test != null) {" as a redundant null check since I've already used test above the
"if" check as if it wasn't null.

I really miss this feature since it helps keep the code clean, and I'd love to see this in NetBeans.

Thanks,
Eric
Comment 1 skiwi 2014-08-20 07:39:39 UTC
This issue is still marked as New, I believe this has been fixed since a few years.