6835430: javac does not generate signature attributes for classes extending parameterized inner classes

ClassWriter does not consider outer params of an inner class when emitting signature attributes

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2009-06-16 10:45:42 +01:00
parent 518efd59c1
commit 5f7f3d4e38
3 changed files with 72 additions and 2 deletions

View File

@ -1521,9 +1521,9 @@ public class ClassWriter extends ClassFile {
int acount = 0;
boolean sigReq =
typarams.length() != 0 || supertype.getTypeArguments().length() != 0;
typarams.length() != 0 || supertype.allparams().length() != 0;
for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail)
sigReq = l.head.getTypeArguments().length() != 0;
sigReq = l.head.allparams().length() != 0;
if (sigReq) {
assert source.allowGenerics();
int alenIdx = writeAttr(names.Signature);

View File

@ -0,0 +1,32 @@
/*
* Copyright 2009 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.
*/
class A<T extends A<T>> {
class C {
public T getT() { return null; }
}
}
class B extends A<B> {
public class D extends A<B>.C {}
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2009 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 6835430
* @summary 6835430: javac does not generate signature attributes for classes extending parameterized inner classes
* @author mcimadamore
*
* @compile A.java
* @compile T6835430.java
*/
class T6835430 {
void test(B.D d) {
B b = d.getT();
}
}