Wildcard capture with self-referencing bound
Zhong Yu
zhong.j.yu at gmail.com
Thu Jun 11 23:40:55 UTC 2015
Elias Vasylenko posted this question on
http://stackoverflow.com/questions/30788366
Given declarations
class C1<T extends C1<T>> {}
class C2<U> extends C1<C2<U>> {}
Are the following parameterization well-formed?
C1<? extends C2<String>>
C1<? extends C2<?>>
According to his interpretation of JLS, which I concur, they are not
well-formed, because the bound of the capture variable, T#1, is C2<String>
& C1<T#1>, which is forbidden by both section $4.9 and $5.1.10. Nothing in
JLS will infer that C2<String> <: C1<T#1>.
However, javac does allow them, which is reasonable, of course. How do we
understand this behavior?
Another question, if Ck in $4.9 contains wildcard like C2<?>, how can we
use it as the superclass of the notional class? How do we derive members of
the notional class?
Thanks,
Zhong Yu
bayou.io
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20150611/ded20252/attachment.html>
More information about the compiler-dev
mailing list