Compiler bug ?
Neal Gafter
neal at gafter.com
Tue Jan 26 08:45:26 PST 2010
Ulf-
Make those variables final and they will be constants. There are
special rules for allowing the conversion of sufficiently small
constants into the type char.
Cheers,
Neal
On Tue, Jan 26, 2010 at 8:30 AM, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> Hi,
>
> i have:
>
> public class EUC_TW_C_d_b_fastLoop1 extends FastCharset implements
> HistoricallyNamedCharset {
>
> private static final byte MIN_BYTE_VALUE = EUC_TWMapping2.MIN_BYTE_VALUE;
> private static final byte MAX_BYTE_VALUE = EUC_TWMapping2.MAX_BYTE_VALUE;
>
> private static final class Encoder extends FastCharset.Encoder {
> static {
> for (char off=0, b1=(MIN_BYTE_VALUE&0xff);
> b1<=(MAX_BYTE_VALUE&0xff); b1++)
> ...
> }
> ...
> }
> ...
> }
>
> This compiles fine, but equivalent code in own class compiles with errors:
>
> final class Enc_d_n_fastLoop1 extends FastCharset.Encoder {
>
> static {
> byte MIN_BYTE_VALUE = EUC_TWMapping2.MIN_BYTE_VALUE;
> byte MAX_BYTE_VALUE = EUC_TWMapping2.MAX_BYTE_VALUE;
>
> for (char off=0, b1=(MIN_BYTE_VALUE&0xff);
> b1<=(MAX_BYTE_VALUE&0xff); b1++)
> ...
> }
> ...
> }
>
> C:\Projects\nio_charset_j7_EUC_TW\src\sun\nio\cs\ext\Enc_d_n_fastLoop1.java:75:
> possible loss of precision
> for (char off=0, b1=(MIN_BYTE_VALUE&0xff);
> b1<=(MAX_BYTE_VALUE&0xff); b1++)
> required: char
> found: int
>
> Is that correct ?
>
> For complete sources see:
> https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/branches/j7_EUC_TW/src/sun/nio/cs/ext/?rev=915
>
> Regards,
>
> -Ulf
>
>
>
>
More information about the compiler-dev
mailing list