FULL PRODUCT VERSION :
javac 1.6.0_07
javac 1.5.0_14
ADDITIONAL OS VERSION INFORMATION :
Linux: 2.6.18-92.1.22.el5
Mac OS X: 10.5.6
A DESCRIPTION OF THE PROBLEM :
An attempt to compile a correct program leads to an internal compiler error (an assertion failure).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the example code. (Seems to be minimal. I can't remove either of the arguments to method foo() and still reproduce the bug.)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiles without error. (The Eclipse compiler will compile it without error.)
ACTUAL -
Quits with an AssertionError.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.6.0_07). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: T?
at com.sun.tools.javac.code.Types.containedBy(Types.java:695)
at com.sun.tools.javac.code.Types$8.visitWildcardType(Types.java:793)
at com.sun.tools.javac.code.Types$8.visitWildcardType(Types.java:747)
at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:416)
at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3143)
at com.sun.tools.javac.code.Types.containsType(Types.java:744)
at com.sun.tools.javac.code.Types.containsType(Types.java:711)
at com.sun.tools.javac.code.Types$5.containsTypeRecursive(Types.java:357)
at com.sun.tools.javac.code.Types$5.visitClassType(Types.java:402)
at com.sun.tools.javac.code.Types$5.visitClassType(Types.java:328)
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3143)
at com.sun.tools.javac.code.Types.isSubtype(Types.java:324)
at com.sun.tools.javac.code.Types.isSubtypeNoCapture(Types.java:311)
at com.sun.tools.javac.code.Types$8.visitWildcardType(Types.java:796)
at com.sun.tools.javac.code.Types$8.visitWildcardType(Types.java:747)
at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:416)
at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3143)
at com.sun.tools.javac.code.Types.containsType(Types.java:744)
at com.sun.tools.javac.code.Types.containsType(Types.java:711)
at com.sun.tools.javac.code.Types$5.containsTypeRecursive(Types.java:357)
at com.sun.tools.javac.code.Types$5.visitClassType(Types.java:402)
at com.sun.tools.javac.code.Types$5.visitClassType(Types.java:328)
at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:3143)
at com.sun.tools.javac.code.Types.isSubtype(Types.java:324)
at com.sun.tools.javac.code.Types.isSubtype(Types.java:308)
at com.sun.tools.javac.code.Types.isSubtypeUnchecked(Types.java:288)
at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:268)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:312)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:542)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:732)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:698)
at com.sun.tools.javac.comp.Resolve.findFun(Resolve.java:778)
at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:1179)
at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1709)
at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:377)
at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1241)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1210)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1017)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1074)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:397)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:413)
at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:715)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:739)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:397)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:634)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:639)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:397)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2691)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2622)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2558)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1036)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:765)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:730)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:69)
at com.sun.tools.javac.Main.main(Main.java:54)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class FailsToCompile {
public void test() {
foo(F1, F2);
}
interface Fun<T, R> { R value(T arg); }
private final Fun<String, String> F1 = null;
private final Fun<Iterable<? extends String>, String> F2 = null;
public static<S, T> void foo(Fun<? super S, ? extends T> f1,
Fun<? super Iterable<T>, ? extends S> f2) {}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use raw types -- cast F2 to a raw Fun.