1

I just stepped over some old code and did a SonarLint analysis. I cannot paste the code here but basically it is similar to:

Object test = new Object[]{"1"};
System.out.println(((Object[])test)[0]); 

This very simple example works, but SonarLint reports an issue on squid:S1905 - Redundant casts should not be used

Any ideas why?

Tester
  • 173
  • 1
  • 10

1 Answers1

0

Unless your reproduction snippet does not exactly mimic the real code, it's a false positive. The cast to Object[] is not redundant, but required. If this is the case, just ignore the issue as a false positive.

M A
  • 71,713
  • 13
  • 134
  • 174
  • Thanks for the answer. I know I can mark this as a false positive but since this is always reproducible I might report it as a bug. – Tester Feb 22 '17 at 15:54