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.
Nonsense example class: public class Bug { public Object getObject() { return null; } public void bug() { Object obj=getObject(); if (obj==null) { switch ("abc") { case "abc": break; default: throw new AssertionError(); } } if (obj==null) // (*) { getClass(); } } } NetBeans reports an "Unnecessary test for null" hint at the line marked as (*), however this hint is wrong. Of course in this nonsense code you instantly ask why I have two if statements for the same test, but in real life you might have other code between them. Anyway, if I remove the line throw new AssertionError(); then the false alarm warning disappears, so obviously NetBeans fails to see that there is a path through the "if (obj==null)" branch that does *not* throw an AssertionError. I'd guess there is no designated treatment of switch statements with breaks while checking whether this warning needs to be displayed.
*** This bug has been marked as a duplicate of bug 249320 ***
Implemented in new version; wait for umbrella issue to close