hg: jdk7/tl/langtools: 2 new changesets
Neal Gafter
neal at gafter.com
Tue Jun 7 17:38:44 PDT 2011
Regarding the fix for "bug" 7041730... I was under the impression that
recent changes to the language and compiler were intended to allow
assignment conversions as casting conversions too. The conversion from the
constant zero (0) to a Byte is among the assignment conversions. Draft SE7
JLS 5.2 (Assignment Conversion) says
In addition, if the expression is a constant expression (§15.28) of type ...
int ... a narrowing primitive conversion followed by a boxing conversion may
be used if the type of the variable is ... Byte and the value of the
constant expression is representable in the type byte...
And 5.5 (Casting Conversion) says
...casting conversions are more inclusive than assignment or method
invocation conversions: a cast can do any permitted conversion other than a
string conversion or a capture conversion (§5.1.10).
Yet this change claims to "fix" the bug 7041730, which requests that the
casting conversion from "0" to "Byte" be illegal; that violates this JLS
quote.
Cheers,
Neal
On Wed, May 11, 2011 at 4:16 AM, <maurizio.cimadamore at oracle.com> wrote:
> Changeset: 95fc7fd39be2
> Author: mcimadamore
> Date: 2011-05-11 13:12 +0200
> URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/95fc7fd39be2
>
> 7041730: Regression: compiler accepts invalid cast from int to Byte
> Summary: Implementation of cast conversion rules between primitive and
> boxed types is too liberal
> Reviewed-by: jjg
>
> ! src/share/classes/com/sun/tools/javac/code/Types.java
> ! test/tools/javac/types/BoxingConversionTest.java
> ! test/tools/javac/types/CastTest.java
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20110607/180fc746/attachment.html
More information about the compiler-dev
mailing list