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

Bug 409245

Summary: [1.8][compiler] Type annotations dropped when call is routed through a synthetic bridge method
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Andrew Clement <aclement>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, srikanth_sankaran
Version: 4.3Flags: srikanth_sankaran: review+
Target Milestone: BETA J8   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 409235    
Attachments:
Description Flags
patch to address the issue none

Description Srikanth Sankaran CLA 2013-05-28 03:57:26 EDT
BETA_JAVA8:

"The Java compiler accepts type annotations and adds them to the program’s AST. 
It writes them to the classfile, including accounting for synthetic methods 
(such as bridge methods) and optimizations" ...

At the moment type annotations are dropped if the call is routed through a
synthetic method.

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=383624#c46, point 1 & 2.
Comment 1 Srikanth Sankaran CLA 2013-05-28 03:57:49 EDT
Thanks for following up Andy.
Comment 2 Andrew Clement CLA 2013-06-12 18:14:01 EDT
Created attachment 232314 [details]
patch to address the issue

I've taken a pass over:

1) calls to CodeStream.invoke that were not passing possibly annotated type arguments
2) calls to the old CodeStream.new_ (that does not take a typereference)

Writing testcases for these scenarios is quite tricky (and is really why addressing these situations weren't covered in the original patch).  Attempting to manufacture something that will be called synthetically *and* that is also something to which you can attach type annotations is not easy.

So I've basically just reviewed all the places where the old invoke was being called and if there are type arguments, they are now passed to the new variant of invoke. In the case of new_ there is only one occurrence and it related to factory method generation (for lambdas I think) - I can't immediately see that this needs to use the new version of new_ so have left it alone.
Comment 3 Srikanth Sankaran CLA 2013-08-05 04:25:50 EDT
Patch looks good - Thanks Andy. You need to sign off on this bugzilla for
Jay to release it. 

Jay, please release and resolve once done. TIA.
Comment 4 Srikanth Sankaran CLA 2013-08-05 04:29:45 EDT
I forgot to mention that the patch as is does not apply. There is a conflict
in the last file: CodeSnippetMessageSend. I had to manually copy over the changes.
I couldn't quite understand why the patch apply fails - though. Several of
Andy's patches seem to have this issue that the last file results in a conflict.
Also https://bugs.eclipse.org/bugs/show_bug.cgi?id=409247
Comment 5 Andrew Clement CLA 2013-08-06 12:41:20 EDT
This contribution complies with http://www.eclipse.org/legal/CoO.php