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

Ulf Zibis Ulf.Zibis at gmx.de
Thu Sep 2 12:28:59 PDT 2010


  Am 02.09.2010 21:07, schrieb Neal Gafter:
> On Wed, Sep 1, 2010 at 6:54 PM, John Rose <john.r.rose at oracle.com <mailto:john.r.rose at oracle.com>> 
> wrote:
>
>
>     (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.
>

Does that mean, that following code is not allowed (see: Bug ID: 6775385 NPE caused by 
ConditionalExpression and auto-boxing failure 
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6775385>):

                 Map<Character,Byte>  c2bExistents = new HashMap();
                 char c = '\u20ac';
                 char directEnd = '\u0080';
                 Byte exsistent = c<  directEnd ? (Byte)(byte)(c) : c2bExistents.get(c);

Workaround looks pretty ugly:

                 Map<Character,Byte>  c2bExistents = new HashMap();
                 char c = '\u20ac';
                 char directEnd = '\u0080';
                 Byte exsistent;
                 if (c<  directEnd)
                     exsistent = (byte)(c);
                 else
                     exsistent = c2bExistents.get(c);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20100902/12b2f57e/attachment.html 


More information about the compiler-dev mailing list