Fri, 03 Dec 2010 16:31:23 +0000
6956758: NPE in com.sun.tools.javac.code.Symbol - isSubClass
Summary: Use of TransTypes.cast() instead of TransTypes.coerce() causes NPE in Lower
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Dec 02 16:38:16 2010 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Dec 03 16:31:23 2010 +0000 1.3 @@ -719,7 +719,7 @@ 1.4 tree.sym = ((MethodSymbol)tree.sym). 1.5 implemented((TypeSymbol)tree.sym.owner, types); 1.6 } 1.7 - tree.selected = cast( 1.8 + tree.selected = coerce( 1.9 translate(tree.selected, erasure(tree.selected.type)), 1.10 erasure(tree.sym.owner.type)); 1.11 } else
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/generics/6956758/T6956758neg.java Fri Dec 03 16:31:23 2010 +0000 2.3 @@ -0,0 +1,20 @@ 2.4 +/* 2.5 + * @test /nodynamiccopyright/ 2.6 + * @bug 6956758 2.7 + * 2.8 + * @summary NPE in com.sun.tools.javac.code.Symbol - isSubClass 2.9 + * @author Maurizio Cimadamore 2.10 + * @compile/fail/ref=T6956758neg.out -XDrawDiagnostics T6956758neg.java 2.11 + * 2.12 + */ 2.13 + 2.14 +class T6956758neg { 2.15 + 2.16 + interface I {} 2.17 + 2.18 + static class C { 2.19 + <T extends Object & I> T cloneObject(T object) throws Exception { 2.20 + return (T)object.clone(); 2.21 + } 2.22 + } 2.23 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/generics/6956758/T6956758neg.out Fri Dec 03 16:31:23 2010 +0000 3.3 @@ -0,0 +1,4 @@ 3.4 +T6956758neg.java:17:29: compiler.err.report.access: clone(), protected, java.lang.Object 3.5 +- compiler.note.unchecked.filename: T6956758neg.java 3.6 +- compiler.note.unchecked.recompile 3.7 +1 error
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/test/tools/javac/generics/6956758/T6956758pos.java Fri Dec 03 16:31:23 2010 +0000 4.3 @@ -0,0 +1,43 @@ 4.4 +/* 4.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.7 + * 4.8 + * This code is free software; you can redistribute it and/or modify it 4.9 + * under the terms of the GNU General Public License version 2 only, as 4.10 + * published by the Free Software Foundation. 4.11 + * 4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 4.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 4.15 + * version 2 for more details (a copy is included in the LICENSE file that 4.16 + * accompanied this code). 4.17 + * 4.18 + * You should have received a copy of the GNU General Public License version 4.19 + * 2 along with this work; if not, write to the Free Software Foundation, 4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 4.21 + * 4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4.23 + * or visit www.oracle.com if you need additional information or have any 4.24 + * questions. 4.25 + */ 4.26 + 4.27 +/* 4.28 + * @test 4.29 + * @bug 6956758 4.30 + * 4.31 + * @summary NPE in com.sun.tools.javac.code.Symbol - isSubClass 4.32 + * @author Maurizio Cimadamore 4.33 + * @compile T6956758pos.java 4.34 + * 4.35 + */ 4.36 + 4.37 +class T6956758pos { 4.38 + 4.39 + interface I {} 4.40 + 4.41 + static class C { 4.42 + <T extends C & I> T cloneObject(T object) throws Exception { 4.43 + return (T)object.clone(); 4.44 + } 4.45 + } 4.46 +}