Community
Participate
Working Groups
3.2 M6 The following code should raise a warning but does not (NullReferenceTest #451): class X { void foo(boolean b) { Object o = new Object(); while (b) { while (b) { o = new Object(); } } if (o != null) { /* */ } // should complain: o cannot be null } }
The issue comes from the projection of potential non null onto potential non null/unknown. Assigned non null + potential non null/unknown yields assigned unknown (the most when can tell), which is not enough to detect that o is non null. Contrast this with test #455, where assigned not null + assigned non null yields assigned non null.
Post 3.2.
Reopening to mark as duplicate.
This bug was fixed along 127570. *** This bug has been marked as a duplicate of 127570 ***