FindBugs considers Class.isInstance. And according to the git history this check was added many years ago. For example this code doesn't trigger BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS:
Nope, neither this code triggers this warning. Have you actually tried? Which version of FindBugs are you using? This code is used to check for isInstance:
I've found the code that lead to me originally creating this issue. The instance check was performed by a static method in the class. Something like...
I see. Well, such kind of interprocedural analysis would be quite hard to implement currently. FindBugs cannot automatically inline such calls now. Ok, I'm reopening this bug. Maybe someday it will be possible.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
FindBugs considers Class.isInstance. And according to the git history this check was added many years ago. For example this code doesn't trigger BC_EQUALS_METHOD_SHOULD_WORK_FOR_ALL_OBJECTS:
However if you remove getClass().isInstance(obj) check, then bug will appear.
If you still experience any problems with isInstance, please provide a test case where false-positive actually occurs. Thanks.
Seeing false positive when using the class property instead of the getClass() method.
Nope, neither this code triggers this warning. Have you actually tried? Which version of FindBugs are you using? This code is used to check for isInstance:
Thus the only restriction is that the argument of isInstance is the parameter of equals method. There's no restriction on the class object itself.
I've found the code that lead to me originally creating this issue. The instance check was performed by a static method in the class. Something like...
We are using FindBugs 3.0.0.
I see. Well, such kind of interprocedural analysis would be quite hard to implement currently. FindBugs cannot automatically inline such calls now. Ok, I'm reopening this bug. Maybe someday it will be possible.