[JSR308] annotation for wildcard types
Chin Wei Ngan
chinwn at comp.nus.edu.sg
Fri Feb 2 00:23:48 EST 2007
> Another question, is annotation types allowed for wildcards ?
> List<? extends @Existing File> and
> List<? super @Existing File>
You raise an interesting question.
I think "File" is meant as a lower/upper bound in
the above typing, rather than the type field
itself. I suppose annotation (if any) ought to
be for the whole of (? extends File), e.g
in pre-fix form:
List<@nonnull (? extends File)>
The "? extends" or "? super" can be viewed as a kind of
type annotation too but this is already part of Java type system,
so it beyond this JSR. I say this because wildcard
type is based on variant parametric type (VPT) which were
originally written as:
List<? extends t> is just a sugar for List<+t>
to help support covariant subtyping. Similarly,
List<? super t> is just a sugar for List<-t>
to support contravariant subtyping. It is tempting to
think of +/- are variance annotations.
More information about the JSR308
mailing list