6660289: declared bound in inner class referring a type variable of the outer class

NPE caused by a defect in type-variable attribution

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2008-03-04 13:00:08 +00:00
parent 9e5259f792
commit 00c5620740
2 changed files with 39 additions and 5 deletions
langtools
src/share/classes/com/sun/tools/javac/comp
test/tools/javac/generics

@ -465,12 +465,12 @@ public class Attr extends JCTree.Visitor {
types.setBounds(a, List.of(syms.objectType));
}
}
}
void attribBounds(List<JCTypeParameter> typarams, Env<AttrContext> env) {
for (JCTypeParameter tvar : typarams)
chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
attribStats(typarams, env);
}
void attribBounds(List<JCTypeParameter> typarams) {
for (JCTypeParameter typaram : typarams) {
Type bound = typaram.type.getUpperBound();
if (bound != null && bound.tsym instanceof ClassSymbol) {
@ -581,7 +581,7 @@ public class Attr extends JCTree.Visitor {
try {
chk.checkDeprecatedAnnotation(tree.pos(), m);
attribBounds(tree.typarams);
attribBounds(tree.typarams, env);
// If we override any other methods, check that we do so properly.
// JLS ???
@ -2687,7 +2687,7 @@ public class Attr extends JCTree.Visitor {
chk.validateAnnotations(tree.mods.annotations, c);
// Validate type parameters, supertype and interfaces.
attribBounds(tree.typarams);
attribBounds(tree.typarams, env);
chk.validateTypeParams(tree.typarams);
chk.validate(tree.extending);
chk.validate(tree.implementing);

@ -0,0 +1,34 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6660289
* @summary declared bound in inner class referring a type variable of the outer class
* @author Maurizio Cimadamore
* @compile T6660289.java
*/
public class T6660289<E> {
class Inner<S extends E> {}
}