Community
Participate
Working Groups
For this syntactic correct program the internal compiler reports a type mismatch for the assignment. import java.util.*; public class A { public <E extends Object,S extends Collection<E>> S test(S param){ Class<? extends Collection> c = param.getClass(); return null; } }
The error is: ---------- 1. ERROR in C:\tests_sources\X.java (at line 6) Class<? extends Collection> c = param.getClass(); ^ Type mismatch: cannot convert from Class<? extends Object> to Class<? extends Collection> ----------
What does the last comment mean? If it means that the given example is not syntactilly correct, try runningthe example with sun's javac
No. Olivier was simply pasting the offending error diagnosis we issue. It clearly is a bug in our compiler.
Problem comes from the fact we didn't intercept the Object#getClass() method on this code path, and did not substitute its return type to be: "Class<? extends Collection>" in place of "Class <? extends Object>". Added regression test: GenericTypeTest#test460. Fixed
Verified in I20050214