receiver annotations

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Nov 28 16:52:48 PST 2012


The following code is in one of the test cases in 
/jdk8/type-annotation/langtools/test/tools/javac/annotations/typeAnnotations/newlocations.

Is this legal? It looks suspicious for having annotations on the type 
parameter X in test3 and test 4.   Surely, the type of the receiver 
should be  exactly as declared after "class", and not with any extra 
annotations. What would be a use case where it makes sense to add 
additional annotations in this location?

-- Jon

class Generic1<X> {
   void test1(Generic1<X> this) {}
   void test2(@A Generic1<X> this) {}
   void test3(Generic1<@A X> this) {}
   void test4(@A Generic1<@A X> this) {}
}


More information about the type-annotations-dev mailing list