hg: jdk7/tl/langtools: 6979683: inconsistent interaction of reference cast with box/unbox conversions leaves out a useful case

Neal Gafter neal at gafter.com
Thu Sep 2 12:07:00 PDT 2010

On Wed, Sep 1, 2010 at 6:54 PM, John Rose <john.r.rose at oracle.com> wrote:

> On Sep 1, 2010, at 6:31 PM, Neal Gafter wrote:
> > I also can't find any general rule about casting being allowed to do the
> reverse of multi-step conversions, which seems to be your "bottom line"
> justification.
> By your reading, what is the spec. support for (Object)(int)x? (I.e.,
> (Object)n, where 'n' is 'int'?)

It was the intent that all the assignment conversions be allowed as casting
conversions too, but this one (and one other) was omitted by mistake.
(Proposed JLS correction sent in private email)

I think the spec. support for (Object)(int) is the use of combined steps
> from the first para. of 5.5.

No, combined steps are not either implicitly or explicitly allowed.  Only
the particular sequences enumerated.  Otherwise you get into loops and
ambiguous conversions.  A similar argument could be made for "Assignment
conversions", but Integer->int->long->Long is not allowed there either.

> (Yes, I agree the spec. is gray here.  There is an umbrella proposal to
> bring clarity to it, mentioned in the final paragraph of my bug report.)

It isn't gray.  Combined conversions are not intended to be allowed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20100902/b681305b/attachment.html 

More information about the compiler-dev mailing list