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.
Created attachment 144103 [details] Example to show the detection bug. The attached code will Hint possible null pointer dereference on the following line: "Class clazz = ex.getClass();" There is no possibility to get there unless the var==null test returns false, because the loop doesn't contain any break's. Note! The example is not going to get out of the do{}while loop unless you add an subclass of the Example class and give the name of it when asked. But as that has nothing to do with this problem I left it out.
I managed to make the example even smaller. public class NullDereferenceHint { public static void main(String[] args) { NullDereferenceHint var; do { var = createNullDereferenceHint(); if (var == null) { System.out.println("NullDereferenceHint still null!"); } } while (var == null); Class clazz = var.getClass(); } public static NullDereferenceHint createNullDereferenceHint() { return new NullDereferenceHint(); } } and finally noticed that if I remove these lines (at the end of do{}while loop): if (var == null) { System.out.println("Example still null!"); } The wrong hint goes away.
Fixed in jet-main#b04c85f5b523
Integrated into 'main-silver', will be available in build *201401220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/b04c85f5b523 User: Svata Dedic <sdedic@netbeans.org> Log: #240643: variable state changed by termination condition pass overrides states from body