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

Tue, 04 Mar 2008 13:00:08 +0000

author
mcimadamore
date
Tue, 04 Mar 2008 13:00:08 +0000
changeset 6
40813968849e
parent 5
b45f8d4794b7
child 7
d472e2fbcc39

6660289: declared bound in inner class referring a type variable of the outer class
Summary: NPE caused by a defect in type-variable attribution
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/T6660289.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Mar 04 12:14:13 2008 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Mar 04 13:00:08 2008 +0000
     1.3 @@ -465,12 +465,12 @@
     1.4                  types.setBounds(a, List.of(syms.objectType));
     1.5              }
     1.6          }
     1.7 +    }
     1.8 +
     1.9 +    void attribBounds(List<JCTypeParameter> typarams, Env<AttrContext> env) {
    1.10          for (JCTypeParameter tvar : typarams)
    1.11              chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
    1.12          attribStats(typarams, env);
    1.13 -    }
    1.14 -
    1.15 -    void attribBounds(List<JCTypeParameter> typarams) {
    1.16          for (JCTypeParameter typaram : typarams) {
    1.17              Type bound = typaram.type.getUpperBound();
    1.18              if (bound != null && bound.tsym instanceof ClassSymbol) {
    1.19 @@ -581,7 +581,7 @@
    1.20          try {
    1.21              chk.checkDeprecatedAnnotation(tree.pos(), m);
    1.22  
    1.23 -            attribBounds(tree.typarams);
    1.24 +            attribBounds(tree.typarams, env);
    1.25  
    1.26              // If we override any other methods, check that we do so properly.
    1.27              // JLS ???
    1.28 @@ -2687,7 +2687,7 @@
    1.29          chk.validateAnnotations(tree.mods.annotations, c);
    1.30  
    1.31          // Validate type parameters, supertype and interfaces.
    1.32 -        attribBounds(tree.typarams);
    1.33 +        attribBounds(tree.typarams, env);
    1.34          chk.validateTypeParams(tree.typarams);
    1.35          chk.validate(tree.extending);
    1.36          chk.validate(tree.implementing);
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/generics/T6660289.java	Tue Mar 04 13:00:08 2008 +0000
     2.3 @@ -0,0 +1,34 @@
     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     6660289
    2.30 + * @summary declared bound in inner class referring a type variable of the outer class
    2.31 + * @author Maurizio Cimadamore
    2.32 + * @compile T6660289.java
    2.33 + */
    2.34 +
    2.35 +public class T6660289<E> {
    2.36 +     class Inner<S extends E> {}
    2.37 +}

mercurial