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 16:13:48 PDT 2010


  Much thanks.

-Ulf


Am 03.09.2010 01:04, schrieb Neal Gafter:
> No, it means that a single cast can't apply multiple conversions from the list of conversions that 
> a cast is allowed to do.  It can only do one of the bullets in that bulleted list.  Programmers 
> can use multiple casts.
>
> On Thu, Sep 2, 2010 at 12:28 PM, Ulf Zibis <Ulf.Zibis at gmx.de <mailto:Ulf.Zibis at gmx.de>> wrote:
>
>     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/20100903/b3c60113/attachment.html 


More information about the compiler-dev mailing list