Interestingly, the java.lang.reflect.WildcardType interface looks like it supports both upper bounds and lower bounds for the arg argument; and each can contain several borders
Type[] getUpperBounds(); Type[] getLowerBounds();
This is much more than the language allows. There's a hidden comment in the source code
// one or many? Up to language spec; currently only one, but this API // allows for generalization.
The author of the interface seems to think this is a random limitation.
The canned answer to your question: generics are already too complicated as they are; adding extra complexity may be the last straw.
In order for the wildcard to have several upper bounds, you need to scan the specification and make sure that the whole system is still working.
One problem that I know will be in type inference. Current withdrawal rules simply cannot deal with interception types. There is no rule to reduce the A&B << C limit. If we reduced it to
A<<C or A<<B
any current output engine must undergo a major overhaul to allow such a bifurcation. But the real serious problem is that it allows you to use several solutions, but there is no reason to prefer each other.
However, no withdrawal is required for security output; we can simply refuse output in this case and ask the programmer to explicitly fill in the type arguments. Therefore, the difficulty in deriving is not a strong argument against the types of interception.
irreputable Jul 11 '11 at 3:19 2011-07-11 03:19
source share