I want to create tree structure with annotation
@Retention(RetentionPolicy.RUNTIME)
public @interface MyNode {
String name();
MyNode next() default null;
}
but compiler tells that it is cycle and hence it is not allowed.
I wonder why it is not allowed and how can I make something like it?
The funny thing is: there is a part of the Java Language specification that seems to contradict this:
But I get a compile error for both this (annotation references itself):
and this (two annotations reference each other):