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 256485

Summary: Mutliple-pass NPE analysis
Product: java Reporter: Svata Dedic <sdedic>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on: 256484, 226083    
Bug Blocks:    

Description Svata Dedic 2015-11-10 07:34:47 UTC
Taking example from issue #226083:

public class Main {

    public static void main(String[] args) {
        Object obj = getObject();
        boolean isOkay = obj != null;
        if (true) {
            obj.toString();
        }
    }

    public static Object getObject() {
        return "something";
    }
}

This code originally provokes a possible NPE hint on obj.toString(). However when analysis of the whole class completes, it becomes known that getObject() never returns null on normal completion. 
This knowledge can be used to recompute data flow for methods which directly calls such a method. Depends on method outcome analysis, see issue #256484