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

John Rose john.r.rose at oracle.com
Wed Sep 1 17:59:42 PDT 2010

On Sep 1, 2010, at 5:43 PM, Neal Gafter wrote:

> You appear to have added a new kind of casting conversion not yet proposed or described in JLS3 (section 5.5).  Is there a language change proposal that corresponds to this code change?

No.  The change reflects logic already present in JLS3, though not (it seems) implemented widely, because (it seems) the spec. has an ambiguity about what conversion sequences are allowed for casts.  In this case, the code is allowing the reverse of certain multi-step conversions which are also defined in the same way by the spec., and (it seems) widely implemented.  See the bug 6979683 for discussion.  If you think our reading of the spec. is somehow wrong, please let Alex know.

Bottom line:  If the spec. allows (Object)(int) it must also be allowing (int)(Object).  My change makes the latter available to users of the RI of javac.

Why now?  Answer: For dynamic language support, specifically in the inner workings of JSR 292 code.

-- John

More information about the compiler-dev mailing list