Community
Participate
Working Groups
I20080930-0921 IBinding#getJavaElement() always returns null for IAnnotationBindings. Fails for source and binary IAnnotationBindings. Javadoc explicitly says: "[..] For annotations, this method * returns the Java element of the annotation (i.e. an {@link IAnnotation})."
Could you please provide an example where you get null?
E.g. open java.lang.annotation.Target from JDK6 and look at the binding for '@Documented'. Same for source, e.g. on binding for @Test, IAnnotationBinding#getJavaElement() returns null: @Test public @interface Test {} Expected: An IAnnotation that is equal to the annotation I get from IAnnotatable#getAnnotations() on the annotated IType.
This seems to be the case only for annotations declared on annotation types. If you write: @Deprecated public interface Test {} it works fine. Updating title accordingly.
Annotations declared on enum types are also wrong.
I have a patch for the source case.
Created attachment 115260 [details] Proposed fix + regression tests Patch for source case. Not sure what can be done for the binary case.
(In reply to comment #6) > Created an attachment (id=115260) [details] > Proposed fix + regression tests Fix is good. Thanks. > Not sure what can be done for the binary case. I'm not sure what you mean. Your fix also solves the case of "@Documented" on java.lang.annotation.Target from JDK6. The only problem is that the element doesn't exist. But this is bug 248309.
Created attachment 115402 [details] Same fix and tests moved to ASTModelBridgeTests
Fix and tests released for 3.5M3
Verified for 3.5M3 using I20081026-2000