diff -r e191909a7c6e Makefile.am --- a/Makefile.am Mon May 30 19:21:44 2011 +0100 +++ b/Makefile.am Wed Jun 01 11:51:40 2011 -0400 @@ -339,7 +339,9 @@ patches/openjdk/7034464-hugepage.patch \ patches/openjdk/7037939-hugepage.patch \ patches/openjdk/7043564-hugepage.patch \ - patches/openjdk/mutter.patch + patches/openjdk/mutter.patch \ + patches/openjdk/6938454-generic-type.patch \ + patches/openjdk/6369605-unconstrained-type-vars.patch if WITH_ALT_HSBUILD ICEDTEA_PATCHES += \ diff -r e191909a7c6e NEWS --- a/NEWS Mon May 30 19:21:44 2011 +0100 +++ b/NEWS Wed Jun 01 11:51:40 2011 -0400 @@ -30,6 +30,8 @@ - S7043054: REGRESSION - wrong userBounds in Paint.createContext() - S7043963, RH698295: Window manager workaround in AWT was not applied to mutter. Now it is. - S4685768: Focus set to disabled component, can't Tab/Shift-Tab + - S6938454: Unable to determine generic type in program that compiles under Java 6. + - S6369605, RH706066: Unconstrained type variables fails to include bounds. * Bug fixes - PR637: make check should exit with an error code if any regression test failed. - G356743: Support libpng 1.5. diff -r e191909a7c6e patches/openjdk/6369605-unconstrained-type-vars.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/6369605-unconstrained-type-vars.patch Wed Jun 01 11:51:40 2011 -0400 @@ -0,0 +1,198 @@ +# HG changeset patch +# User mcimadamore +# Date 1281967090 -3600 +# Node ID dc550520ed6fc1af0b19b482020807194bfd1335 +# Parent 27bae58329d5d492c8c9ae42f3897a02f39b88d5 +6369605: Unconstrained type variables fails to include bounds +Summary: unconstrained type-variables with recursive bounds are not inferred properly +Reviewed-by: jjg + +diff -r 27bae58329d5 -r dc550520ed6f src/share/classes/com/sun/tools/javac/code/Type.java +--- openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Mon Aug 16 14:56:23 2010 +0100 ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Mon Aug 16 14:58:10 2010 +0100 +@@ -347,11 +347,17 @@ + return false; + } + +- /** Does this type contain an occurrence of some type in `elems'? ++ /** Does this type contain an occurrence of some type in 'ts'? + */ +- public boolean containsSome(List ts) { +- for (List l = ts; l.nonEmpty(); l = l.tail) +- if (this.contains(ts.head)) return true; ++ public boolean containsAny(List ts) { ++ for (Type t : ts) ++ if (this.contains(t)) return true; ++ return false; ++ } ++ ++ public static boolean containsAny(List ts1, List ts2) { ++ for (Type t : ts1) ++ if (t.containsAny(ts2)) return true; + return false; + } + +@@ -431,6 +437,10 @@ + this.bound = bound; + } + ++ public boolean contains(Type t) { ++ return kind != UNBOUND && type.contains(t); ++ } ++ + public boolean isSuperBound() { + return kind == SUPER || + kind == UNBOUND; +@@ -681,7 +691,9 @@ + return + elem == this + || (isParameterized() +- && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem))); ++ && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem))) ++ || (isCompound() ++ && (supertype_field.contains(elem) || contains(interfaces_field, elem))); + } + + public void complete() { +diff -r 27bae58329d5 -r dc550520ed6f src/share/classes/com/sun/tools/javac/comp/Infer.java +--- openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Aug 16 14:56:23 2010 +0100 ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Aug 16 14:58:10 2010 +0100 +@@ -138,24 +138,73 @@ + /** A mapping that returns its type argument with every UndetVar replaced + * by its `inst' field. Throws a NoInstanceException + * if this not possible because an `inst' field is null. ++ * Note: mutually referring undertvars will be left uninstantiated ++ * (that is, they will be replaced by the underlying type-variable). + */ ++ + Mapping getInstFun = new Mapping("getInstFun") { + public Type apply(Type t) { + switch (t.tag) { +- case UNKNOWN: +- throw ambiguousNoInstanceException +- .setMessage("undetermined.type"); +- case UNDETVAR: +- UndetVar that = (UndetVar) t; +- if (that.inst == null) ++ case UNKNOWN: + throw ambiguousNoInstanceException +- .setMessage("type.variable.has.undetermined.type", +- that.qtype); +- return apply(that.inst); +- default: +- return t.map(this); ++ .setMessage("undetermined.type"); ++ case UNDETVAR: ++ UndetVar that = (UndetVar) t; ++ if (that.inst == null) ++ throw ambiguousNoInstanceException ++ .setMessage("type.variable.has.undetermined.type", ++ that.qtype); ++ return isConstraintCyclic(that) ? ++ that.qtype : ++ apply(that.inst); ++ default: ++ return t.map(this); + } + } ++ ++ private boolean isConstraintCyclic(UndetVar uv) { ++ Types.UnaryVisitor constraintScanner = ++ new Types.UnaryVisitor() { ++ ++ List seen = List.nil(); ++ ++ Boolean visit(List ts) { ++ for (Type t : ts) { ++ if (visit(t)) return true; ++ } ++ return false; ++ } ++ ++ public Boolean visitType(Type t, Void ignored) { ++ return false; ++ } ++ ++ @Override ++ public Boolean visitClassType(ClassType t, Void ignored) { ++ if (t.isCompound()) { ++ return visit(types.supertype(t)) || ++ visit(types.interfaces(t)); ++ } else { ++ return visit(t.getTypeArguments()); ++ } ++ } ++ @Override ++ public Boolean visitWildcardType(WildcardType t, Void ignored) { ++ return visit(t.type); ++ } ++ ++ @Override ++ public Boolean visitUndetVar(UndetVar t, Void ignored) { ++ if (seen.contains(t)) { ++ return true; ++ } else { ++ seen = seen.prepend(t); ++ return visit(t.inst); ++ } ++ } ++ }; ++ return constraintScanner.visit(uv); ++ } + }; + + /*************************************************************************** +@@ -257,10 +306,9 @@ + TypeVar tv = (TypeVar)uv.qtype; + ListBuffer hibounds = new ListBuffer(); + for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) { +- if (!t.containsSome(that.tvars) && t.tag != BOT) { +- hibounds.append(t); +- } ++ hibounds.append(types.subst(t, that.tvars, undetvars)); + } ++ + List inst = that.getConstraints(tv, ConstraintKind.EQUAL); + if (inst.nonEmpty() && inst.head.tag != BOT) { + uv.inst = inst.head; +@@ -279,9 +327,32 @@ + + // check bounds + List targs = Type.map(undetvars, getInstFun); +- targs = types.subst(targs, that.tvars, targs); ++ if (Type.containsAny(targs, that.tvars)) { ++ //replace uninferred type-vars ++ targs = types.subst(targs, ++ that.tvars, ++ instaniateAsUninferredVars(undetvars, that.tvars)); ++ } + return chk.checkType(warn.pos(), that.inst(targs, types), to); + } ++ //where ++ private List instaniateAsUninferredVars(List undetvars, List tvars) { ++ ListBuffer new_targs = ListBuffer.lb(); ++ //step 1 - create syntethic captured vars ++ for (Type t : undetvars) { ++ UndetVar uv = (UndetVar)t; ++ Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null); ++ new_targs = new_targs.append(newArg); ++ } ++ //step 2 - replace synthetic vars in their bounds ++ for (Type t : new_targs.toList()) { ++ CapturedType ct = (CapturedType)t; ++ ct.bound = types.subst(ct.bound, tvars, new_targs.toList()); ++ WildcardType wt = new WildcardType(ct.bound, BoundKind.EXTENDS, syms.boundClass); ++ ct.wildcard = wt; ++ } ++ return new_targs.toList(); ++ } + + /** Instantiate method type `mt' by finding instantiations of + * `tvars' so that method can be applied to `argtypes'. +--- openjdk.orig/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Mon Aug 16 14:56:23 2010 +0100 ++++ openjdk/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Mon Aug 16 14:58:10 2010 +0100 +@@ -1,2 +1,2 @@ T6638712a.java:16:41: compiler.err.inval +-T6638712a.java:16:41: compiler.err.invalid.inferred.types: T, (- compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable>, java.util.List>) ++T6638712a.java:16:41: compiler.err.prob.found.req: (- compiler.misc.incompatible.types.1: (- compiler.misc.no.conforming.instance.exists: T, java.util.Comparator, java.util.Comparator)), java.util.Comparator, java.util.Comparator + 1 error + diff -r e191909a7c6e patches/openjdk/6938454-generic-type.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/6938454-generic-type.patch Wed Jun 01 11:51:40 2011 -0400 @@ -0,0 +1,153 @@ +# HG changeset patch +# User mcimadamore +# Date 1280415385 -3600 +# Node ID 36c4ec4525b41f0c0d6b60c227c916a34631e03c +# Parent ed354a00f76b78f11e6a96c308cc76d1c6a28884 +6938454: Unable to determine generic type in program that compiles under Java 6 +Summary: a redundant dubtyping check causes spurious inference failure +Reviewed-by: jjg + +diff -r ed354a00f76b -r 36c4ec4525b4 src/share/classes/com/sun/tools/javac/comp/Infer.java +--- openjdk.orig/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Jul 27 11:52:11 2010 -0700 ++++ openjdk/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Jul 29 15:56:25 2010 +0100 +@@ -256,7 +256,7 @@ + UndetVar uv = (UndetVar) l.head; + TypeVar tv = (TypeVar)uv.qtype; + ListBuffer hibounds = new ListBuffer(); +- for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS).prependList(types.getBounds(tv))) { ++ for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) { + if (!t.containsSome(that.tvars) && t.tag != BOT) { + hibounds.append(t); + } +@@ -280,7 +280,6 @@ + // check bounds + List targs = Type.map(undetvars, getInstFun); + targs = types.subst(targs, that.tvars, targs); +- checkWithinBounds(that.tvars, targs, warn); + return chk.checkType(warn.pos(), that.inst(targs, types), to); + } + +@@ -398,7 +397,7 @@ + UndetVar uv = (UndetVar)t; + if (uv.qtype == tv) { + switch (ck) { +- case EXTENDS: return uv.hibounds; ++ case EXTENDS: return uv.hibounds.appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes)); + case SUPER: return uv.lobounds; + case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.nil(); + } +@@ -458,7 +457,7 @@ + + /** check that type parameters are within their bounds. + */ +- private void checkWithinBounds(List tvars, ++ void checkWithinBounds(List tvars, + List arguments, + Warner warn) + throws InvalidInstanceException { +diff -r ed354a00f76b -r 36c4ec4525b4 test/tools/javac/generics/inference/6938454/T6938454a.java +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ openjdk/langtools/test/tools/javac/generics/inference/6938454/T6938454a.java Thu Jul 29 15:56:25 2010 +0100 +@@ -0,0 +1,47 @@ ++/* ++ * Copyright 2010 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 6938454 ++ * ++ * @summary Unable to determine generic type in program that compiles under Java 6 ++ * @author mcimadamore ++ * @compile T6938454a.java ++ * ++ */ ++ ++class T6938454a { ++ ++ static abstract class A { } ++ ++ static class B extends A { } ++ ++ B getB(B b) { ++ return makeA(b); ++ } ++ ++ Y makeA(X x) { ++ return (Y)new B(); ++ } ++} +diff -r ed354a00f76b -r 36c4ec4525b4 test/tools/javac/generics/inference/6938454/T6938454b.java +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ openjdk/langtools/test/tools/javac/generics/inference/6938454/T6938454b.java Thu Jul 29 15:56:25 2010 +0100 +@@ -0,0 +1,49 @@ ++/* ++ * Copyright 2010 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. ++ */ ++ ++import java.util.List; ++ ++/* ++ * @test ++ * @bug 6938454 ++ * ++ * @summary Unable to determine generic type in program that compiles under Java 6 ++ * @author mcimadamore ++ * @compile T6938454b.java ++ * ++ */ ++ ++class T6938454b { ++ ++ static interface A {} ++ static interface B extends A {} ++ static class C implements B {} ++ ++ List m(List l, S s) { ++ return null; ++ } ++ ++ List test(List la) { ++ return m(la, new C()); ++ } ++} +exporting patch: +