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 251969

Summary: NPECheck does not handle boolean XOR
Product: java Reporter: jo.navy
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 7.4   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 249320    
Bug Blocks:    

Description jo.navy 2015-04-21 14:28:32 UTC
Consider this piece of code:

    Object o = null;
    if ((o != null) ^ false) { // ^ false is a NOP
        throw new RuntimeException();
    }
    if (o == null) { // NetBeans: "Unnecessary test for null - the expression is never null"
    }


NetBeans says "the expression is never null" but, on the contrary, it is always null.
Comment 1 jo.navy 2015-04-21 14:35:38 UTC
Also note that the wrong hint disappears if you remove the bitwise XOR from the first "if" statement.

Perhaps this bug is related to https://netbeans.org/bugzilla/show_bug.cgi?id=249234
Comment 2 Svata Dedic 2015-06-02 12:12:19 UTC
Will be fixed as part of issue #249320
Comment 3 Svata Dedic 2015-09-10 13:28:09 UTC

*** This bug has been marked as a duplicate of bug 245201 ***
Comment 4 Svata Dedic 2015-11-10 17:30:06 UTC
Fixed in experimental impl, wait for the umbrella issue to close.