Tue, 13 Jan 2009 13:31:35 +0000
6558559: Extra "unchecked" diagnostic
Summary: Fixed Types.sideCast in order to suppress redundant unchecked warnings
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jan 13 13:28:42 2009 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jan 13 13:31:35 2009 +0000 1.3 @@ -3148,7 +3148,7 @@ 1.4 giveWarning = giveWarning || (reverse ? giveWarning(t2, t1) : giveWarning(t1, t2)); 1.5 commonSupers = commonSupers.tail; 1.6 } 1.7 - if (giveWarning && !isReifiable(to)) 1.8 + if (giveWarning && !isReifiable(reverse ? from : to)) 1.9 warn.warnUnchecked(); 1.10 if (!source.allowCovariantReturns()) 1.11 // reject if there is a common method signature with
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/cast/6558559/T6558559a.java Tue Jan 13 13:31:35 2009 +0000 2.3 @@ -0,0 +1,40 @@ 2.4 +/* 2.5 + * Copyright 2008 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 6558559 2.30 + * @summary Extra "unchecked" diagnostic 2.31 + * @author Maurizio Cimadamore 2.32 + * 2.33 + * @compile T6558559a.java -Xlint:unchecked -Werror 2.34 + */ 2.35 + 2.36 +class T6558559a { 2.37 + interface A<T> {} 2.38 + 2.39 + static class B<T> {} 2.40 + 2.41 + A<?> x = null; 2.42 + B<?> y = (B<?>)x; 2.43 +} 2.44 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/cast/6558559/T6558559b.java Tue Jan 13 13:31:35 2009 +0000 3.3 @@ -0,0 +1,43 @@ 3.4 +/* 3.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 3.24 + * have any questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 6558559 3.30 + * @summary Extra "unchecked" diagnostic 3.31 + * @author Maurizio Cimadamore 3.32 + * 3.33 + * @compile T6558559b.java -Xlint:unchecked -Werror 3.34 + */ 3.35 + 3.36 +import java.util.*; 3.37 + 3.38 +class T6558559b { 3.39 + void test(List rawList, List<?> unboundList) { 3.40 + Throwable t0 = (Throwable) Collections.emptyList(); 3.41 + Throwable t1 = (Throwable) rawList; 3.42 + Throwable t2 = (Throwable) unboundList; 3.43 + Object o = unboundList; 3.44 + Throwable t3 = (Throwable) o; 3.45 + } 3.46 +} 3.47 \ No newline at end of file