Should JSR308 forbid type annotations on uses of a type parameter ?

Srikanth S Adayapalam srikanth_sankaran at in.ibm.com
Wed Sep 11 22:35:30 PDT 2013


Hello !

I am trying to understand if there are valid scenarios where type 
annotating the use of a type
variable actually makes sense. The following program compiles fine with 
both eclipse and 
javac 8b100:
 
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target(ElementType.TYPE_USE)
@interface TA {
}
@Target(ElementType.TYPE_USE)
@interface TB {
}

public abstract class X<@TA T> {

                 @TB T t;
}

Studying this test case, since both occurrence of T would denote the 
same type instantiation, does it make sense to think of "only @TA 
annotated T" and "only @TB annotated T" ? 

Shouldn't the language insist that they be consolidated and presented all 
at the declaration site ? 

Have I overlooked any valid scenarios where this would actually make sense 
?

Thanks!
Srikanth


More information about the type-annotations-spec-experts mailing list