Annotation cycles (was: repeating annotations)
    Jesse Glick 
    jesse.glick at oracle.com
       
    Tue Apr 17 05:59:13 PDT 2012
    
    
  
On 03/11/2012 06:19 PM, Joe Darcy wrote:
> two annotation types cannot be containers for each other because that would create an illegal cyclic annotation type situation
So long as you are changing the language spec for annotations, why not fix this longstanding irritation too (#6264216), which arbitrarily prevents a rather wide range of 
use cases for annotations? For example, move the cycle check from declaration time to use time, so that the only rejected constructs would be genuinely nonterminating 
cycles that no one would ever intentionally write:
@interface A {
   B[] bs() default {@B};
}
@interface B {
  A as() default {@A};
}
@A class X {} // oops
but so that legitimate cases compile:
@interface A {
   B[] bs() default {};
}
@interface B {
   A[] as() default {};
}
@A(@B(@A)) class X {} // fine
    
    
More information about the compiler-dev
mailing list