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 268249

Summary: Unnecessary test for null complain even when this test is necessary
Product: ide Reporter: ilya.e.g
Component: CodeAssignee: issues@ide <issues>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log

Description ilya.e.g 2016-09-28 13:37:04 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.8.0_92
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.92-b14

Reproducibility: Happens every time

STEPS:
Please have a look at the following code:

    public static boolean nullSafeEquals(final Object obj1, final Object obj2) {
        return obj1 == null & obj2 == null || obj1 != null && obj1.equals(obj2);
    }

The check for null:
 obj1 != null
is necessary to prevent a NullPointerException, and the old version of Netbeans (7.4) demands that check.
But new version 8.0.1 and 8.1 claims that test as unnecessary, but it is necessary
ACTUAL:
    Unnecessary test for null - the expression is never null

EXPECTED:
  This check is necessary, as it was in  the 7.4 versio
Comment 1 ilya.e.g 2016-09-28 13:37:11 UTC
Created attachment 162255 [details]
IDE log