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.
I prepared the following snippet to help understand the problem: 0 public void function(int[] array1, int[] array2){ 1 if (array1 == null | array2 == null){ 2 throw new NullPointerException(); 3 } 4 if (array1.length != array2.length){ 5 //Do something 6 } 7 } In that code the "Dereferencing null pointer" hint appears on line 4, but if in line 2 we use the short circuit operand || the hint goes away. Anyway it's impossible for a NullPointerException to be thrown on line 4 using either | or ||. Regards Product Version = NetBeans IDE 7.4 (Build 201310111528) Operating System = Linux version 3.11.0-12-generic running on amd64 Java; VM; Vendor = 1.7.0_45 Runtime = Java HotSpot(TM) 64-Bit Server VM 24.45-b08
reproducible
An additional defect: boolean foo = array1 != null; if (array.length == 1) { // <- a warning appears, provoked by array1 != null. } speculative values created by == and != comparison operators leak to a permanent variable state set.
OK, correction ;) Lahvac reminded me that != or == may be seen as a hint that the programmer supposes the value *might* be sometimes null; so values which are subject to != or == operator should be checked as if null was a possible value. So my example is incorrect - not a bug.
Fixed in http://hg.netbeans.org/jet-main/rev/4db3851709d0