Community
Participate
Working Groups
Compilation of the following interface fails: interface I<T extends I<? super T>> {} with: "Bound mismatch: The type ? super T is not a valid substitute for the bounded parameter <T extends I<? super T>> of the type I<T>" The compiler tries to assure that the *eventual* substitute of "? super T" is valid by checking it against the original bound of I: "T extends I<...>". The proper way is to check the *implementers* of this interface to assure that their proposed type parameters are within bounds, not the bound definition itself. The code should only fail if it could be guaranteed that no implementer may satisfy the bounds (which is obviously not the case here) Note 1: compiling with javac -Xlint:all gives no warnings or errors whatsoever. Note 2: interestingly, following compiles, although it *should* be in the same category as the code above: interface I<T extends I< ? extends T>> {} Interestingly as well, interface I<T extends I< ? super I>> {} compiles in contrast to javac, but class I<T extends I< ? super I<?>>> {} does not compile in agreement with javac. Node 3: Sun's javac (5.0) is problematic too, try interface I<T extends I<? extends I<? super T>>> {} for a funny 1029 line long stack trace of a stack overflow. -- Irfy
Correction for Note 3: Taking my words back about the compiler, after updating to JDK 1.5.0_01 :-). It now works with SUN's javac, but Eclipse still does not accept it. For the curious, the stack overflow can be reproduced with JDK 1.5.0-rc -- Irfy
Bound checks still need to occur when resolving type parameter bounds. I suspect it just needs some tuning.
Fixed by tuning bound check wrt to super wildcard. Added GenericTypeTest#test609.
Fixed
Released
Verified in I20050510-0010