Hi,
FindBug unable to detect all such violations at once. It reports only first and then stops.
Upon fixing or commenting it detects next.
A boxed value is unboxed and then immediately reboxed.
---------------------------- code --------------------
import java.math.BigDecimal;
public class BoxingTest {
public static void main(String[] args) {
Object x = new BigDecimal(0);
// Violation is reported correctly for this statement.
// A boxed value is unboxed and then immediately reboxed.
Double result = (x instanceof BigDecimal) ? ((BigDecimal) x)
.doubleValue() : (Double) x;
// Same violation is present on this line.
// But findbugs does not report violation for this line.
Double result1 = (x instanceof BigDecimal) ? ((BigDecimal) x)
.doubleValue() : (Double) x;
System.out.println(result);
System.out.println(result1);
}
}
----------------- code -------------------
Regards,
Rajesh