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.
Given: if (Expression instanceof SomeType) { ... } Netbeans should mark this branch if there is no way Expression will ever be of type SomeType. I would suggest either marking the entire branch in gray to denote it is unused or flag it with a warning-hint.
Could you please be more specific about when the branch should be considered dead? AFAIK, a compile-time error occurs if it is provable at compile-time that the instanceof condition can never be true.
It is true that this is the case if Expression and SomeType are both concrete classes, but if one is an interface you will not get a compile-time error because it is conceivably possible that in some distant future it might be true. Here is a specific example: ArrayList foo = null; if (foo instanceof Map) System.out.println("No compile-time error"); There are two possible scenarios as far as I can tell: 1) Some project contains the above code. The branch will *never* execute because we know the runtime value of "foo" and it can never be an instanceof Map (javac applies a very superficial check so it misses this fact). Netbeans should mark this branch as gray to indicate it can be removed (or is a programming mistake). 2) Project A contains the following code: public SomeMethod(ArrayList foo) { if (foo instanceof Map) System.out.println("No compile-time error"); } Project B depends on Project A passes in an implementation of ArrayList that implements Map. The code branch will then be exercised. In such a case Netbeans can't mark the branch gray because it has no way of knowing what value is passed in.
@_gtzabari: Fixed in my own plugin. https://github.com/markiewb/nb-additional-hints/issues/44 Give it a try and feedback. @Svata: Or do you like to have this integrated natively in NB? I only adapted some old code from Jan Lahoda to make it possible https://github.com/markiewb/nb-additional-hints/commit/4aef4a880a54cfa7a9c5d6400602c1b27d2226a5