Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314029

Summary: Array-typed class references of annotations are not properly resolved
Product: [Eclipse Project] JDT Reporter: Gunnar Morling <gunnar.morling>
Component: APTAssignee: Generic inbox for the JDT-APT component <jdt-apt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: eclipse, gunnar.morling
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: stalebug
Attachments:
Description Flags
An Eclipse workspace demonstrating the bug none

Description Gunnar Morling CLA 2010-05-22 19:32:11 EDT
Build Identifier: 20100520-1308

Let there be two annotations:

public @interface MyMetaAnnotation {
	
	Class<?> value();
	
	Class<?>[] arrayValue();
	
}

and 

@MyMetaAnnotation(value = A.class, arrayValue = {A.class, B.class})
public @interface MyAnnotation {
	
}

Let there furthermore be a class using MyAnnotation:

public class MyModel {
	
	@MyAnnotation
	public int foo;

}

An annotation processor processing MyModel now should be able to navigate from foo to @MyAnnotation to @MyMetaAnnotation and examine the values of "value" and "arrayValue". While this works fine for the simple reference "value" (in especially the members of the referenced type "A" can be retrieved) this doesn't work for the array-typed reference "arrayValue" (in especially a call to getEnclosedElements() to retrieve the members of the referenced types "A" and "B" returns an empty list).

The outcome seems to depend on whether the annotations are defined within the same project as the type using it (in this case cleaning the project sometimes helps and the bug doesn't occur) or not.

This bug can not be reproduced using the Sun Java compiler and its JSR 269 implementation.

Reproducible: Always

Steps to Reproduce:
1. Extract and open the attached Eclipse workspace.
2. Build the contained projects and add the contained AP to project ap-2
3. Go to "error log", the members of the types referenced in @MyMetaAnnotation#arrayValue() should be displayed there, but aren't.

More information on the test case can be found in the readme.txt within the attached archive.
Comment 1 Gunnar Morling CLA 2010-05-22 19:40:40 EDT
Created attachment 169600 [details]
An Eclipse workspace demonstrating the bug
Comment 2 Walter Harley CLA 2010-05-22 20:30:57 EDT
Thanks for the clear report.  I'll look into it.
Comment 3 Eclipse Genie CLA 2020-02-19 20:00:44 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.