6816548: Uninitialized register when performing casting + auto(un)boxing

Wed, 25 Mar 2009 10:28:52 +0000

author
mcimadamore
date
Wed, 25 Mar 2009 10:28:52 +0000
changeset 253
6ce39250fa88
parent 252
5caa6c45936a
child 254
1ee128971f5d

6816548: Uninitialized register when performing casting + auto(un)boxing
Summary: Constant value of final variable is lost during lowering
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/Lower.java file | annotate | diff | comparison | revisions
test/tools/javac/boxing/T6816548.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Mar 25 10:28:36 2009 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Mar 25 10:28:52 2009 +0000
     1.3 @@ -2631,8 +2631,8 @@
     1.4          if (havePrimitive) {
     1.5              Type unboxedTarget = types.unboxedType(type);
     1.6              if (unboxedTarget.tag != NONE) {
     1.7 -                if (!types.isSubtype(tree.type, unboxedTarget))
     1.8 -                    tree.type = unboxedTarget; // e.g. Character c = 89;
     1.9 +                if (!types.isSubtype(tree.type, unboxedTarget)) //e.g. Character c = 89;
    1.10 +                    tree.type = unboxedTarget.constType(tree.type.constValue());
    1.11                  return (T)boxPrimitive((JCExpression)tree, type);
    1.12              } else {
    1.13                  tree = (T)boxPrimitive((JCExpression)tree);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/boxing/T6816548.java	Wed Mar 25 10:28:52 2009 +0000
     2.3 @@ -0,0 +1,66 @@
     2.4 +/*
     2.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.24 + * have any questions.
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * @test
    2.29 + * @bug     6816548
    2.30 + * @summary Uninitialized register when performing casting + auto(un)boxing
    2.31 + * @author  mcimadamore
    2.32 + */
    2.33 +public class T6816548 {
    2.34 +
    2.35 +    public static void main(String[] args) {
    2.36 +        testInt();
    2.37 +        testShort();
    2.38 +        testByte();
    2.39 +        testChar();
    2.40 +    }
    2.41 +
    2.42 +    public static void testInt() {
    2.43 +        final int fi = 0;
    2.44 +        Byte b = fi;
    2.45 +        Short s = fi;
    2.46 +        Character c = fi;
    2.47 +    }
    2.48 +
    2.49 +    public static void testShort() {
    2.50 +        final short fs = 0;
    2.51 +        Byte b = fs;
    2.52 +        Short s = fs;
    2.53 +        Character c = fs;
    2.54 +    }
    2.55 +
    2.56 +    public static void testByte() {
    2.57 +        final byte fb = 0;
    2.58 +        Byte b = fb;
    2.59 +        Short s = fb;
    2.60 +        Character c = fb;
    2.61 +    }
    2.62 +
    2.63 +    public static void testChar() {
    2.64 +        final char fc = '0';
    2.65 +        Byte b = fc;
    2.66 +        Short s = fc;
    2.67 +        Character c = fc;
    2.68 +    }
    2.69 +}

mercurial