Originally Posted by
fortioni
Why should the cast to Object[] be flagged though?
Will you flag casts to List<SomeClass>[] as well?
How about any cast?
Because that is essentially what you are suggesting...casting is always suspicious.
Which, to be frank, is nonsense.
Almost any artifact of a language is open to misuse.
I'm curious, in your work have you encountered a problem with this aspect of Java?
Because in over a decade working in it I honestly can't think of any in the stuff I've written or reviewed.
Same goes for type erasure as well, as a matter of fact.
Now, automatic primitive wrapping...that keeps causing trouble.
No. The "nonsense" suggestion is entirely your own. Nowhere have I suggested flag all casts. If a cast fails at runtime, you know exactly where to look in the source code because it will tell you.
You are still avoiding addressing the scenario in my last but one post, which is why you think any old cast is equivalent.
The problem here is impact analysis. Earlier versions of Java didn't even flag the function declaration in the varargs problem. They only flagged the invocation. Now they've move the compiler error closer to the source of the error. But, as I said, please address the scenario, so that you comment more accurately on my perspective.