Fri, 20 Jun 2014 10:56:31 -0600
8034147: javac crashes with a NullPointerException during bounds checking
Summary: Types.supertype should return Type.noType rather than null
Reviewed-by: vromero, mcimadamore
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jun 20 11:42:16 2014 -0600 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jun 20 10:56:31 2014 -0600 1.3 @@ -2300,7 +2300,7 @@ 1.4 public Type visitType(Type t, Void ignored) { 1.5 // A note on wildcards: there is no good way to 1.6 // determine a supertype for a super bounded wildcard. 1.7 - return null; 1.8 + return Type.noType; 1.9 } 1.10 1.11 @Override 1.12 @@ -2467,7 +2467,7 @@ 1.13 return false; 1.14 return 1.15 t.isRaw() || 1.16 - supertype(t) != null && isDerivedRaw(supertype(t)) || 1.17 + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || 1.18 isDerivedRaw(interfaces(t)); 1.19 } 1.20
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jun 20 11:42:16 2014 -0600 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jun 20 10:56:31 2014 -0600 2.3 @@ -2679,7 +2679,7 @@ 2.4 checkClassBounds(pos, seensofar, it); 2.5 } 2.6 Type st = types.supertype(type); 2.7 - if (st != null) checkClassBounds(pos, seensofar, st); 2.8 + if (st != Type.noType) checkClassBounds(pos, seensofar, st); 2.9 } 2.10 2.11 /** Enter interface into into set.
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/generics/wildcards/T8034147.java Fri Jun 20 10:56:31 2014 -0600 3.3 @@ -0,0 +1,35 @@ 3.4 +/* 3.5 + * Copyright (c) 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/* 3.28 + * @test 3.29 + * @bug 8034147 3.30 + * @summary javac crashes with a NullPointerException during bounds checking 3.31 + * @compile T8034147.java 3.32 + */ 3.33 + 3.34 +class T8034147 { 3.35 + static class One<X extends Two<? super X>> {} 3.36 + static class Two<Y extends Three<? extends Y>> implements Three<Y> {} 3.37 + interface Three<Z> {} 3.38 +}