armando fonseca wrote:Correct me if I'm wrong ruben , but I don't see widening, I see a narrowing and then boxing:
Short <- Object <- Byte <- byte <- int
is my assumption correct?
Armando,
The issue with your chain of conversions is that you can't have an implicit reference narrowing conversion (in your case that would be from Object to Short.) This is what is commonly called reference downcasting, and it requires an explicit use of the casting operator.
This is an interesting problem. Either I can't find something in the JLS, the JLS is missing something, or javac is not doing what it should. I'm leaning towards the first option, because otherwise my unshakable faith in the
Java gods will be disturbed for ever (just kidding.)