Bug 85538

Summary: [1.5] compiler does not reject cyclic annotation element types
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gunnar, ilias
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Keller CLA 2005-02-16 14:53:28 EST
I20050215-2300

The compiler must reject cyclic annotation element types.
Javac spits out an error for nest(): "cyclic annotation element type".

@Retention(RetentionPolicy.RUNTIME)
@interface Nested {
	String name() default "Hans";
	N2 nest();
}

@interface N2 {
	Nested n2() default @Nested(name="Haus", nest= @N2);
}

Running the following class then gives a StackOverflowError (cyclic annotations
seem to pass through the verifier without problems):

@Nested(name="XY", nest= @N2)
class Test {
	public static void main(String[] args) {
		Nested annotation= Test.class.getAnnotation(Nested.class);
	}
}
Comment 1 Philipe Mulet CLA 2005-02-16 16:08:40 EST
*** Bug 81974 has been marked as a duplicate of this bug. ***
Comment 2 Kent Johnson CLA 2005-02-23 10:24:10 EST
Added to AnnotationTest test003
Comment 3 David Audel CLA 2005-03-31 07:01:21 EST
Verified in I20050330-0500