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

Bug 568240

Summary: Method's annotation attribute is compiled as annotation on return type
Product: [Eclipse Project] JDT Reporter: Benjamin G <bgaraude>
Component: CoreAssignee: Srikanth Sankaran <srikanth.sankaran>
Status: CLOSED MOVED QA Contact:
Severity: normal    
Priority: P3 CC: srikanth.sankaran
Version: 4.17   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:
Attachments:
Description Flags
Test case none

Description Benjamin G CLA 2020-10-26 05:42:28 EDT
Created attachment 284564 [details]
Test case

If I have an annotation 'Ann' whose @Target is METHOD.
This annotation declares an attribute value whose type is another annotation 'Child' without @Target.

Then, I annotate a method with this annotation and compile it with JDT.

When I call getAnnotatedReturnType() on the java.lang.Method, I receive an array with one element being the @Child annotation. 

If I compile the code with javac, getAnnotatedReturnType() returns an empty array, which seems correct.

A workaround is to add @Target({}) on @Child, in this case, JDT behaves as javac.

This occurs on eclipse 2020-09.

I've attached a test case that reproduces the issue.
If you compile it with eclipse, you should reproduce the issue. While compiled with javac, the test passes.
Comment 1 Eclipse Genie CLA 2023-02-04 19:46:17 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.

If you have further information on the current state of the bug, please add it. 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.
Comment 2 Srikanth Sankaran CLA 2023-06-01 02:49:39 EDT
This is fixed by https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1096, I will carry over the test case from here into the PR https://github.com/eclipse-jdt/eclipse.jdt.core/pull/1097