J2SE Version (please include all output from java -version flag):
java version "1.6.0_10"
Does this problem occur on J2SE 1.3, 1.4.x or 1.5? Yes / No (pick one)
Not tested, however 1.6.0_02 and 1.6.0_04 produce the same problem.
Operating System Configuration Information (be specific):
Windows Server 2003 SP 2
Hardware Configuration Information (be specific):
Toshiba Tecra S5
Bug Description:
javac does not compile correct source code with generics.
Input:
abstract class Test
{
interface Fn<T, R> { }
interface Pair<T1, T2> { }
abstract <T> java.util.Comparator<T> asComparator(Fn<Pair<? extends T, ? extends T>, Integer> fn);
<X> void test(Fn<Pair<? extends X, ? extends X>, Integer> fn)
{
asComparator(fn); // <- compile error
}
// On the other hand:
interface Single<T1> { }
abstract <T> java.util.Comparator<T> asComparator2(Fn<Single<? extends T>, Integer> fn);
<X> void test2(Fn<Single<? extends X>, Integer> fn)
{
asComparator2(fn); // compiles fine
}
}
Output:
Test.java:12: <T>asComparator(Test.Fn<Test.Pair<? extends T,? extends T>,java.lang.Integer>) in Test cannot be applied to (Test.Fn<Test.Pair<? extends X,? extends X>,java.lang.Integer>)
asComparator(fn); // <- compile error
^
1 error
Workaround:
this.<X> asComparator(fn);