Tue, 15 Apr 2008 17:48:22 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Fri Apr 11 15:08:21 2008 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Apr 15 17:48:22 2008 -0700 1.3 @@ -640,6 +640,10 @@ 1.4 return typarams_field; 1.5 } 1.6 1.7 + public boolean hasErasedSupertypes() { 1.8 + return isRaw(); 1.9 + } 1.10 + 1.11 public Type getEnclosingType() { 1.12 return outer_field; 1.13 } 1.14 @@ -711,6 +715,17 @@ 1.15 } 1.16 } 1.17 1.18 + public static class ErasedClassType extends ClassType { 1.19 + public ErasedClassType(Type outer, TypeSymbol tsym) { 1.20 + super(outer, List.<Type>nil(), tsym); 1.21 + } 1.22 + 1.23 + @Override 1.24 + public boolean hasErasedSupertypes() { 1.25 + return true; 1.26 + } 1.27 + } 1.28 + 1.29 public static class ArrayType extends Type 1.30 implements javax.lang.model.type.ArrayType { 1.31
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Apr 11 15:08:21 2008 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Apr 15 17:48:22 2008 -0700 2.3 @@ -1499,47 +1499,68 @@ 2.4 * type parameters in t are deleted. 2.5 */ 2.6 public Type erasure(Type t) { 2.7 + return erasure(t, false); 2.8 + } 2.9 + //where 2.10 + private Type erasure(Type t, boolean recurse) { 2.11 if (t.tag <= lastBaseTag) 2.12 return t; /* fast special case */ 2.13 else 2.14 - return erasure.visit(t); 2.15 + return erasure.visit(t, recurse); 2.16 } 2.17 // where 2.18 - private UnaryVisitor<Type> erasure = new UnaryVisitor<Type>() { 2.19 - public Type visitType(Type t, Void ignored) { 2.20 + private SimpleVisitor<Type, Boolean> erasure = new SimpleVisitor<Type, Boolean>() { 2.21 + public Type visitType(Type t, Boolean recurse) { 2.22 if (t.tag <= lastBaseTag) 2.23 return t; /*fast special case*/ 2.24 else 2.25 - return t.map(erasureFun); 2.26 + return t.map(recurse ? erasureRecFun : erasureFun); 2.27 } 2.28 2.29 @Override 2.30 - public Type visitWildcardType(WildcardType t, Void ignored) { 2.31 - return erasure(upperBound(t)); 2.32 + public Type visitWildcardType(WildcardType t, Boolean recurse) { 2.33 + return erasure(upperBound(t), recurse); 2.34 } 2.35 2.36 @Override 2.37 - public Type visitClassType(ClassType t, Void ignored) { 2.38 - return t.tsym.erasure(Types.this); 2.39 + public Type visitClassType(ClassType t, Boolean recurse) { 2.40 + Type erased = t.tsym.erasure(Types.this); 2.41 + if (recurse) { 2.42 + erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym); 2.43 + } 2.44 + return erased; 2.45 } 2.46 2.47 @Override 2.48 - public Type visitTypeVar(TypeVar t, Void ignored) { 2.49 - return erasure(t.bound); 2.50 + public Type visitTypeVar(TypeVar t, Boolean recurse) { 2.51 + return erasure(t.bound, recurse); 2.52 } 2.53 2.54 @Override 2.55 - public Type visitErrorType(ErrorType t, Void ignored) { 2.56 + public Type visitErrorType(ErrorType t, Boolean recurse) { 2.57 return t; 2.58 } 2.59 }; 2.60 + 2.61 private Mapping erasureFun = new Mapping ("erasure") { 2.62 public Type apply(Type t) { return erasure(t); } 2.63 }; 2.64 2.65 + private Mapping erasureRecFun = new Mapping ("erasureRecursive") { 2.66 + public Type apply(Type t) { return erasureRecursive(t); } 2.67 + }; 2.68 + 2.69 public List<Type> erasure(List<Type> ts) { 2.70 return Type.map(ts, erasureFun); 2.71 } 2.72 + 2.73 + public Type erasureRecursive(Type t) { 2.74 + return erasure(t, true); 2.75 + } 2.76 + 2.77 + public List<Type> erasureRecursive(List<Type> ts) { 2.78 + return Type.map(ts, erasureRecFun); 2.79 + } 2.80 // </editor-fold> 2.81 2.82 // <editor-fold defaultstate="collapsed" desc="makeCompoundType"> 2.83 @@ -1626,15 +1647,14 @@ 2.84 if (t.supertype_field == null) { 2.85 List<Type> actuals = classBound(t).allparams(); 2.86 List<Type> formals = t.tsym.type.allparams(); 2.87 - if (actuals.isEmpty()) { 2.88 - if (formals.isEmpty()) 2.89 - // Should not happen. See comments below in interfaces 2.90 - t.supertype_field = supertype; 2.91 - else 2.92 - t.supertype_field = erasure(supertype); 2.93 - } else { 2.94 + if (t.hasErasedSupertypes()) { 2.95 + t.supertype_field = erasureRecursive(supertype); 2.96 + } else if (formals.nonEmpty()) { 2.97 t.supertype_field = subst(supertype, formals, actuals); 2.98 } 2.99 + else { 2.100 + t.supertype_field = supertype; 2.101 + } 2.102 } 2.103 } 2.104 return t.supertype_field; 2.105 @@ -1708,18 +1728,15 @@ 2.106 assert t != t.tsym.type : t.toString(); 2.107 List<Type> actuals = t.allparams(); 2.108 List<Type> formals = t.tsym.type.allparams(); 2.109 - if (actuals.isEmpty()) { 2.110 - if (formals.isEmpty()) { 2.111 - // In this case t is not generic (nor raw). 2.112 - // So this should not happen. 2.113 - t.interfaces_field = interfaces; 2.114 - } else { 2.115 - t.interfaces_field = erasure(interfaces); 2.116 - } 2.117 - } else { 2.118 + if (t.hasErasedSupertypes()) { 2.119 + t.interfaces_field = erasureRecursive(interfaces); 2.120 + } else if (formals.nonEmpty()) { 2.121 t.interfaces_field = 2.122 upperBounds(subst(interfaces, formals, actuals)); 2.123 } 2.124 + else { 2.125 + t.interfaces_field = interfaces; 2.126 + } 2.127 } 2.128 } 2.129 return t.interfaces_field;
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Apr 11 15:08:21 2008 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Apr 15 17:48:22 2008 -0700 3.3 @@ -1810,7 +1810,7 @@ 3.4 chk.earlyRefError(tree.pos(), sym.kind == VAR ? sym : thisSym(tree.pos(), env)); 3.5 } 3.6 Env<AttrContext> env1 = env; 3.7 - if (sym.kind != ERR && sym.owner != null && sym.owner != env1.enclClass.sym) { 3.8 + if (sym.kind != ERR && sym.kind != TYP && sym.owner != null && sym.owner != env1.enclClass.sym) { 3.9 // If the found symbol is inaccessible, then it is 3.10 // accessed through an enclosing instance. Locate this 3.11 // enclosing instance: 3.12 @@ -1878,8 +1878,10 @@ 3.13 boolean varArgs = env.info.varArgs; 3.14 tree.sym = sym; 3.15 3.16 - if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR) 3.17 - site = capture(site.getUpperBound()); 3.18 + if (site.tag == TYPEVAR && !isType(sym) && sym.kind != ERR) { 3.19 + while (site.tag == TYPEVAR) site = site.getUpperBound(); 3.20 + site = capture(site); 3.21 + } 3.22 3.23 // If that symbol is a variable, ... 3.24 if (sym.kind == VAR) {
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Apr 11 15:08:21 2008 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Apr 15 17:48:22 2008 -0700 4.3 @@ -1247,7 +1247,7 @@ 4.4 for (Type t2 = sup; 4.5 t2.tag == CLASS; 4.6 t2 = types.supertype(t2)) { 4.7 - for (Scope.Entry e2 = t1.tsym.members().lookup(s1.name); 4.8 + for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); 4.9 e2.scope != null; 4.10 e2 = e2.next()) { 4.11 Symbol s2 = e2.sym; 4.12 @@ -1394,6 +1394,16 @@ 4.13 while (e.scope != null) { 4.14 if (m.overrides(e.sym, origin, types, false)) 4.15 checkOverride(tree, m, (MethodSymbol)e.sym, origin); 4.16 + else if (e.sym.isInheritedIn(origin, types) && !m.isConstructor()) { 4.17 + Type er1 = m.erasure(types); 4.18 + Type er2 = e.sym.erasure(types); 4.19 + if (types.isSameType(er1,er2)) { 4.20 + log.error(TreeInfo.diagnosticPositionFor(m, tree), 4.21 + "name.clash.same.erasure.no.override", 4.22 + m, m.location(), 4.23 + e.sym, e.sym.location()); 4.24 + } 4.25 + } 4.26 e = e.next(); 4.27 } 4.28 }
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Fri Apr 11 15:08:21 2008 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Apr 15 17:48:22 2008 -0700 5.3 @@ -690,13 +690,15 @@ 5.4 5.5 public void visitSelect(JCFieldAccess tree) { 5.6 Type t = tree.selected.type; 5.7 - if (t.isCompound() || (t.tag == TYPEVAR && t.getUpperBound().isCompound())) { 5.8 + while (t.tag == TYPEVAR) 5.9 + t = t.getUpperBound(); 5.10 + if (t.isCompound()) { 5.11 if ((tree.sym.flags() & IPROXY) != 0) { 5.12 tree.sym = ((MethodSymbol)tree.sym). 5.13 implemented((TypeSymbol)tree.sym.owner, types); 5.14 } 5.15 tree.selected = cast( 5.16 - translate(tree.selected, erasure(t)), 5.17 + translate(tree.selected, erasure(tree.selected.type)), 5.18 erasure(tree.sym.owner.type)); 5.19 } else 5.20 tree.selected = translate(tree.selected, erasure(t));
6.1 --- a/src/share/classes/com/sun/tools/javac/parser/Parser.java Fri Apr 11 15:08:21 2008 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Parser.java Tue Apr 15 17:48:22 2008 -0700 6.3 @@ -1006,7 +1006,10 @@ 6.4 break loop; 6.5 case DOT: 6.6 S.nextToken(); 6.7 + int oldmode = mode; 6.8 + mode &= ~NOPARAMS; 6.9 typeArgs = typeArgumentsOpt(EXPR); 6.10 + mode = oldmode; 6.11 if ((mode & EXPR) != 0) { 6.12 switch (S.token()) { 6.13 case CLASS:
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/tools/javac/generics/5009937/T5009937.java Tue Apr 15 17:48:22 2008 -0700 7.3 @@ -0,0 +1,41 @@ 7.4 +/* 7.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 7.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 7.24 + * have any questions. 7.25 + */ 7.26 + 7.27 +/* 7.28 + * @test 7.29 + * @bug 5009937 7.30 + * @summary hiding versus generics versus binary compatibility 7.31 + * @author Maurizio Cimadamore 7.32 + * 7.33 + * @compile/fail/ref=T5009937.out -XDstdout -XDrawDiagnostics T5009937.java 7.34 + */ 7.35 + 7.36 +public class T5009937<X> { 7.37 + static class A { 7.38 + static void m(T5009937<String> l) {} 7.39 + } 7.40 + 7.41 + static class B extends A { 7.42 + static void m(T5009937<Integer> l) {} 7.43 + } 7.44 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/tools/javac/generics/5009937/T5009937.out Tue Apr 15 17:48:22 2008 -0700 8.3 @@ -0,0 +1,2 @@ 8.4 +T5009937.java:39:21: compiler.err.name.clash.same.erasure.no.override: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A 8.5 +1 error
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/generics/6531075/T6531075.java Tue Apr 15 17:48:22 2008 -0700 9.3 @@ -0,0 +1,66 @@ 9.4 +/* 9.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 9.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 9.24 + * have any questions. 9.25 + */ 9.26 + 9.27 +/* 9.28 + * @test 9.29 + * @bug 6531075 9.30 + * 9.31 + * @summary Missing synthetic casts when accessing fields/methods of intersection types including type variables 9.32 + * @author Maurizio Cimadamore 9.33 + * 9.34 + */ 9.35 + 9.36 + 9.37 +public class T6531075 { 9.38 + 9.39 + static class A { 9.40 + void a() {} 9.41 + } 9.42 + 9.43 + static interface I{ 9.44 + void i(); 9.45 + } 9.46 + 9.47 + static class E extends A implements I{ 9.48 + public void i() {} 9.49 + } 9.50 + 9.51 + static class C<W extends A & I, T extends W>{ 9.52 + T t; 9.53 + W w; 9.54 + C(W w, T t) { 9.55 + this.w = w; 9.56 + this.t = t; 9.57 + } 9.58 + } 9.59 + 9.60 + public static void main(String... args) { 9.61 + C<E,E> c = new C<E,E>(new E(), new E()); 9.62 + testMemberMethods(c); 9.63 + } 9.64 + 9.65 + static void testMemberMethods(C<?, ?> arg) { 9.66 + arg.t.a(); 9.67 + arg.t.i(); 9.68 + } 9.69 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/generics/Casting5.java Tue Apr 15 17:48:22 2008 -0700 10.3 @@ -0,0 +1,45 @@ 10.4 +/* 10.5 + * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 10.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 10.24 + * have any questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 6559182 10.30 + * @summary Cast from a raw type with non-generic supertype to a raw type fails unexpectedly 10.31 + * @author Maurizio Cimadamore 10.32 + * 10.33 + * @compile Casting5.java 10.34 + */ 10.35 + 10.36 +class Casting5 { 10.37 + static interface Super<P> {} 10.38 + static class Y implements Super<Integer>{} 10.39 + static interface X extends Super<Double>{} 10.40 + static class S<L> extends Y {} 10.41 + static interface T<L> extends X {} 10.42 + 10.43 + public static void main(String... args) { 10.44 + S s = null; // same if I use S<Byte> 10.45 + T t = null; // same if I use T<Byte> 10.46 + t = (T) s; 10.47 + } 10.48 +}
11.1 --- a/test/tools/javac/generics/InheritanceConflict.java Fri Apr 11 15:08:21 2008 -0700 11.2 +++ b/test/tools/javac/generics/InheritanceConflict.java Tue Apr 15 17:48:22 2008 -0700 11.3 @@ -25,7 +25,7 @@ 11.4 * @test 11.5 * @bug 4984158 11.6 * @summary two inherited methods with same signature 11.7 - * @author gafter 11.8 + * @author gafter, Maurizio Cimadamore 11.9 * 11.10 * @compile/fail -source 1.5 InheritanceConflict.java 11.11 */ 11.12 @@ -34,8 +34,11 @@ 11.13 11.14 class A<T> { 11.15 void f(String s) {} 11.16 +} 11.17 + 11.18 +class B<T> extends A<T> { 11.19 void f(T t) {} 11.20 } 11.21 11.22 -class B extends A<String> { 11.23 +class C extends B<String> { 11.24 }
12.1 --- a/test/tools/javac/generics/InheritanceConflict2.java Fri Apr 11 15:08:21 2008 -0700 12.2 +++ b/test/tools/javac/generics/InheritanceConflict2.java Tue Apr 15 17:48:22 2008 -0700 12.3 @@ -25,7 +25,7 @@ 12.4 * @test 12.5 * @bug 4984158 12.6 * @summary two inherited methods with same signature 12.7 - * @author gafter 12.8 + * @author gafter, Maurizio Cimadamore 12.9 * 12.10 * @compile -source 1.5 InheritanceConflict2.java 12.11 */ 12.12 @@ -34,9 +34,12 @@ 12.13 12.14 class A<T> { 12.15 void f(String s) {} 12.16 +} 12.17 + 12.18 +class B<T> extends A<T> { 12.19 void f(T t) {} 12.20 } 12.21 12.22 -class B extends A<String> { 12.23 +class C extends B<String> { 12.24 void f(String s) {} 12.25 }
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/generics/T6481655.java Tue Apr 15 17:48:22 2008 -0700 13.3 @@ -0,0 +1,41 @@ 13.4 +/* 13.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 13.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 13.24 + * have any questions. 13.25 + */ 13.26 + 13.27 +/* 13.28 + * @test 13.29 + * @bug 6481655 13.30 + * @summary Parser confused by combination of parens and explicit type args 13.31 + * @author Maurizio Cimadamore 13.32 + */ 13.33 + 13.34 +public class T6481655 { 13.35 + 13.36 + public static <T> T getT(T t) { 13.37 + return t; 13.38 + } 13.39 + 13.40 + public static void main(String... s) { 13.41 + T6481655.<String>getT(""); 13.42 + (T6481655.<String>getT("")).getClass(); 13.43 + } 13.44 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/generics/T6657499.java Tue Apr 15 17:48:22 2008 -0700 14.3 @@ -0,0 +1,44 @@ 14.4 +/* 14.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 14.24 + * have any questions. 14.25 + */ 14.26 + 14.27 +/* 14.28 + * @test 14.29 + * 14.30 + * @bug 6657499 14.31 + * @summary generics: javac 1.6.0 fails to compile class with inner class 14.32 + * @author Maurizio Cimadamore 14.33 + * 14.34 + */ 14.35 + 14.36 +public class T6657499<T> { 14.37 + T t; 14.38 + public T test() { 14.39 + class Local {private T t;}; 14.40 + class Local2 {T m() {return t;}}; 14.41 + T t3 = new Local().t; 14.42 + return new Local2().m(); 14.43 + } 14.44 + public static void main(String[] args) { 14.45 + String s = new T6657499<String>().test(); 14.46 + } 14.47 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/generics/inference/6356673/T6365166.java Tue Apr 15 17:48:22 2008 -0700 15.3 @@ -0,0 +1,40 @@ 15.4 +/* 15.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 15.24 + * have any questions. 15.25 + */ 15.26 + 15.27 +/** 15.28 + * @test 15.29 + * @bug 6365166 15.30 + * @summary javac (generic) unable to resolve methods 15.31 + * @author Maurizio Cimadamore 15.32 + * 15.33 + * @compile T6365166.java 15.34 + */ 15.35 + 15.36 +import java.util.*; 15.37 + 15.38 +public class T6365166 { 15.39 + static <A> void add(List<? super A> l, List<A> la) { 15.40 + l.addAll(la); //doesn't compile - but it should 15.41 + } 15.42 +} 15.43 +
16.1 --- a/test/tools/javac/generics/inference/6611449/T6611449.java Fri Apr 11 15:08:21 2008 -0700 16.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.java Tue Apr 15 17:48:22 2008 -0700 16.3 @@ -29,18 +29,18 @@ 16.4 */ 16.5 public class T6611449<S> { 16.6 16.7 - T6611449() {this(1);} 16.8 - 16.9 - <T extends S> T6611449(T t1) {this(t1, 1);} 16.10 + <T extends S> T6611449(T t1) {} 16.11 16.12 <T extends S> T6611449(T t1, T t2) {} 16.13 16.14 - <T extends S> void m(T t1) {} 16.15 + <T extends S> void m1(T t1) {} 16.16 16.17 - <T extends S> void m(T t1, T t2) {} 16.18 + <T extends S> void m2(T t1, T t2) {} 16.19 16.20 void test() { 16.21 + new T6611449<S>(1); 16.22 + new T6611449<S>(1, 1); //internal error: lub is erroneously applied to primitive types 16.23 m1(1); 16.24 - m2(1, 1); 16.25 + m2(1, 1); //internal error: lub is erroneously applied to primitive types 16.26 } 16.27 }
17.1 --- a/test/tools/javac/generics/inference/6611449/T6611449.out Fri Apr 11 15:08:21 2008 -0700 17.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out Tue Apr 15 17:48:22 2008 -0700 17.3 @@ -1,5 +1,5 @@ 17.4 -T6611449.java:32:17: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449<S> 17.5 -T6611449.java:34:35: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (T,int), , (- compiler.misc.kindname.class), T6611449<S> 17.6 -T6611449.java:43:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m1, (int), , (- compiler.misc.kindname.class), T6611449<S> 17.7 -T6611449.java:44:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.method), m2, (int,int), , (- compiler.misc.kindname.class), T6611449<S> 17.8 +T6611449.java:41:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int), , (- compiler.misc.kindname.class), T6611449<S> 17.9 +T6611449.java:42:9: compiler.err.cant.resolve.location: (- compiler.misc.kindname.constructor), T6611449, (int,int), , (- compiler.misc.kindname.class), T6611449<S> 17.10 +T6611449.java:43:9: compiler.err.cant.apply.symbol: <T>m1(T), T6611449<S>, , int, null 17.11 +T6611449.java:44:9: compiler.err.cant.apply.symbol: <T>m2(T,T), T6611449<S>, , int,int, null 17.12 4 errors
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/generics/wildcards/T6450290.java Tue Apr 15 17:48:22 2008 -0700 18.3 @@ -0,0 +1,44 @@ 18.4 +/* 18.5 + * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. 18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 + * 18.8 + * This code is free software; you can redistribute it and/or modify it 18.9 + * under the terms of the GNU General Public License version 2 only, as 18.10 + * published by the Free Software Foundation. 18.11 + * 18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.15 + * version 2 for more details (a copy is included in the LICENSE file that 18.16 + * accompanied this code). 18.17 + * 18.18 + * You should have received a copy of the GNU General Public License version 18.19 + * 2 along with this work; if not, write to the Free Software Foundation, 18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.21 + * 18.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 18.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 18.24 + * have any questions. 18.25 + */ 18.26 + 18.27 +/* 18.28 + * @test 18.29 + * @bug 6450290 18.30 + * @summary Capture of nested wildcards causes type error 18.31 + * @author Maurizio Cimadamore 18.32 + * @compile/fail T6450290.java 18.33 + */ 18.34 + 18.35 +public class T6450290 { 18.36 + static class Box<X extends Box<?,?>, T extends X> { 18.37 + T value; 18.38 + Box<X, T> same; 18.39 + } 18.40 + 18.41 + static class A extends Box<A,A> {} 18.42 + static class B extends Box<B,B> {} 18.43 + public static void main(String[] args) { 18.44 + Box<?,?> b = new Box<Box<A,A>,Box<A,A>>(); 18.45 + b.value.same = new Box<B,B>(); //javac misses this bad assignment 18.46 + } 18.47 +}