Community
Participate
Working Groups
System: - Eclipse 3.1M2 - Mandrake 10.0 This code exhibits inconsistant behavior on the Sun and Eclipse compilers. interface AA<W, Z extends AA<W, Z>> { public boolean m(AA<W, ?> that); public Z z(); public boolean b(); } abstract class BB<U, V extends AA<U, V>> implements AA<U,V> { public boolean m(AA<U, ?> wht) { return wht.z().b(); } } Note that - The formal type parameter Z of AA is bounded recursively by AA, - But the corresponding type argument of the declared type of formal parameter wht of method m's implementation is a wildcard with no bound. My understanding of unbounded wildcards is as an implicit bound of Object, which in this case means that in the body of m the expression "wht.z()" should be assumed to be Object, which does not have a method b(). The Eclipse compiler seems to reject this code for this reason:"'Bound mismatch: the type ? is not a valid substitute for the bounded parameter <Z extends AA<W,Z>> of type AA<W,Z>". On the other hand, any validly constructed actual parameter wht of type AA<U, ?> would certainly have been constructed respecting the bounds on Z. Perhaps this is why the Sun JDK javac accepts this code without error? I do not know which is the correct behavior, and am posting this bug to both the JDK and Eclipse bug pages. (Interface AA, by itself, compiles without error on both compilers.)
JDT compiler still complains with last build I200410260800: ---------- 1. ERROR in D:\usr\OTI\workspaces\dvpt\v31\HEAD\_Bug\BB.java (at line 2) public boolean m(AA<U, ?> wht) { return wht.z().b(); } ^ Bound mismatch: The type ? is not a valid substitute for the bounded parameter <Z extends AA<W,Z>> of the type AA<W,Z> ---------- 1 problem (1 error)
Added regression test: GenericTypeTest#test378.
Rewrote the type argument comparisons. Fixed
Verified for 3.1 M3 with build I200411040800