Recently, I've read a lot about Java Generics since I'm going to start a project which heavily depends on those mechanics and the public reflection API allowing accessing them. But in my understanding, those are a bit contradicting:
Note, a wildcard can have only one bound. In can neither have both an upper and a lower bound nor several upper or lower bounds. Constructs such as " ? super Long extends Number " or " ? extends Comparable & Cloneable " are illegal.
(http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeArguments.html#FAQ102; section Wildcard Bounds)
Thus, a wildcard always has only one bound (if you ignore the upper bound "Object" that goes with every lower bound wildcard). But if you look at the corresponding reflection API class WildcardType
, it seems like that this is not the whole truth:
Why does the API only provide the functions getLowerBounds()
and getLowerBounds()
and why do they return an array? Is there any scenario, in which an array with a length of at least two will be returned?
Aucun commentaire:
Enregistrer un commentaire