Probably it's not very important problem as BC_UNCONFIRMED_CAST is switched off by default, but at least it worth reporting. Feel free to reject if fixing such case is too difficult.
public class TestCast { public double getValue(Object obj) { if(obj instanceof Number || obj instanceof String) { if(obj instanceof Number) { return ((Number)obj).doubleValue(); } else { return Double.parseDouble((String)obj); } } else { throw new IllegalArgumentException(); } } }
FindBugs 2.0.2 reports at TestCast.java, line 8:
Bug: Unchecked/unconfirmed cast from java.io.Serializable to String in TestCast.getValue(Object) This cast is unchecked, and not all instances of the type casted from can be cast to the type it is being cast to. Check that your program logic ensures that this cast will not fail. Confidence: Low, Rank: Of Concern (20) Pattern: BC_UNCONFIRMED_CAST Type: BC, Category: STYLE (Dodgy code)
Program logic clearly displays that cast to String is completely safe.
Really hard to fix, and the code is pretty bad and should be rewritten anyway.