Bug 427745 - [1.8][compiler]javac compatibility @Retention Runtime ignored
Summary: [1.8][compiler]javac compatibility @Retention Runtime ignored
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.4 M7   Edit
Assignee: Sasikanth Bharadwaj CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 437446 (view as bug list)
Depends on:
Blocks: 404648
  Show dependency tree
 
Reported: 2014-02-09 01:21 EST by Manoj N Palat CLA
Modified: 2014-08-26 02:37 EDT (History)
3 users (show)

See Also:


Attachments
Changes to carry annotations to bridge methods (851 bytes, patch)
2014-04-08 04:25 EDT, Sasikanth Bharadwaj CLA
no flags Details | Diff
mylyn/context/zip (233.10 KB, application/octet-stream)
2014-04-08 04:25 EDT, Sasikanth Bharadwaj CLA
no flags Details
Patch to carry annotations to bridge methods (2.95 KB, patch)
2014-04-08 07:41 EDT, Sasikanth Bharadwaj CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manoj N Palat CLA 2014-02-09 01:21:06 EST
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;

public class X extends Super {
    public static void main(String[] args) {
        try {
            Method m = X.class.getMethod("setFoo", String.class);
            Annotation a = m.getAnnotation(Anno.class);
            System.out.println("Annotation was " + (a == null ? "not " : "") + "found");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class Super {
    @Anno
    public void setFoo(String foo) {}
}
@Retention(RetentionPolicy.RUNTIME)
@interface Anno {}

MethodVerifyTest#208
On running the above, javac finds ("Annotation was found") the annotation while eclipse jdt does not. The behaviour was "Annotation not found" in 1.7 in javac as well. Looks like it was a bug that got fixed in javac. b126 in 1.7 mode also finds the annotations. - [May have to move out of 1.8 as well after analysis.]
Comment 1 Srikanth Sankaran CLA 2014-02-09 05:38:40 EST
javac has started carrying over annotations to the bridge. This is an interesting
behavior change, we will take a look at it in 4.4 time frame.
Comment 2 Srikanth Sankaran CLA 2014-03-25 23:32:39 EDT
Sasi, please take a look.
Comment 3 Sasikanth Bharadwaj CLA 2014-04-08 04:25:35 EDT
Created attachment 241709 [details]
Changes to carry annotations to bridge methods

Changes to Carry annotations to bridge methods
Comment 4 Sasikanth Bharadwaj CLA 2014-04-08 04:25:47 EDT
Created attachment 241710 [details]
mylyn/context/zip
Comment 5 Sasikanth Bharadwaj CLA 2014-04-08 04:35:53 EDT
Srikanth, please look at proposed patch to carry annotations to bridge methods. The tests test208, test208a, test288658 and test288658a in MethodVerifyTest need to be modified after this change to pass.
Comment 6 Srikanth Sankaran CLA 2014-04-08 04:42:37 EDT
(In reply to Sasikanth Bharadwaj from comment #4)
> Created attachment 241710 [details]
> mylyn/context/zip

I don't use mylyn, so these are not useful for me.

(In reply to Sasikanth Bharadwaj from comment #5)
> Srikanth, please look at proposed patch to carry annotations to bridge
> methods. The tests test208, test208a, test288658 and test288658a in
> MethodVerifyTest need to be modified after this change to pass.

Could you post a patch that also includes the tests please ? Thanks.
Comment 7 Sasikanth Bharadwaj CLA 2014-04-08 07:41:01 EDT
Created attachment 241721 [details]
Patch to carry annotations to bridge methods

Patch that includes modifications to tests as well
Comment 8 Sasikanth Bharadwaj CLA 2014-04-08 07:42:48 EDT
(In reply to comment #6)
> (In reply to Sasikanth Bharadwaj from comment #4)
> > Created attachment 241710 [details]
> > mylyn/context/zip
> 
> I don't use mylyn, so these are not useful for me.
> 
> (In reply to Sasikanth Bharadwaj from comment #5)
> > Srikanth, please look at proposed patch to carry annotations to bridge
> > methods. The tests test208, test208a, test288658 and test288658a in
> > MethodVerifyTest need to be modified after this change to pass.
> 
> Could you post a patch that also includes the tests please ? Thanks.
New patch that includes modifications to tests is attached.

Thanks
Sasikanth
Comment 9 Sasikanth Bharadwaj CLA 2014-04-15 02:56:31 EDT
My contribution for this defect fix complies with http://www.eclipse.org/legal/CoO.php
Comment 10 Srikanth Sankaran CLA 2014-04-15 04:07:10 EDT
Patch looks good. With minor changed released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=fbdad6f7f08557483f413498112ee14ccf916e02
Comment 11 Jay Arthanareeswaran CLA 2014-04-29 05:09:59 EDT
Verified for 4.4 M7 with build I20140428-2000
Comment 12 Srikanth Sankaran CLA 2014-08-26 02:37:45 EDT
*** Bug 437446 has been marked as a duplicate of this bug. ***