changeset 5:40813968849e

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
author mcimadamore
date Tue, 04 Mar 2008 13:00:08 +0000
parents b45f8d4794b7
children d472e2fbcc39
files src/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/generics/T6660289.java
diffstat 2 files changed, 39 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Mar 04 12:14:13 2008 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Mar 04 13:00:08 2008 +0000
@@ -465,12 +465,12 @@
                 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 @@
         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 @@
         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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/T6660289.java	Tue Mar 04 13:00:08 2008 +0000
@@ -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> {}
+}