Queries about JDK-8035890

Jan Lahoda jan.lahoda at oracle.com
Thu Mar 13 12:38:09 UTC 2014


Hello,

I have two questions on JDK-8035890 - any insights on them are very welcome.

1. Consider this source code:
---
public class AnnotAfterTypeParams {
     public <T> @Decl int foo() { return 0; }
}
@interface Decl { }
---

javac currently accepts this code - is that correct? (I could not find a 
point in the specification to support this.)

2. Consider this source code:
---
import java.lang.annotation.*;
public class AnnotCopiedToAnonymous {
     private Object o = new @Annot Object() { };
}
@Target({ElementType.TYPE, ElementType.TYPE_USE})
@interface Annot { }
---

The generated anonymous innerclass (AnnotCopiedToAnonymous$1) has the 
Annot annotation as a declaration annotation in its 
RuntimeInvisibleAnnotations in addition to having it in its 
RuntimeInvisibleTypeAnnotations with a supertype target. Is it intended 
to have the annotation as a declaration annotation?

Thanks,
     Jan


More information about the type-annotations-dev mailing list