Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349488 - [1.7] IMethodBinding#getMethodDeclaration() should return the declaration of @PolymorphicSignature methods
Summary: [1.7] IMethodBinding#getMethodDeclaration() should return the declaration of ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-15 14:41 EDT by Markus Keller CLA
Modified: 2011-08-05 02:54 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix + regression test (13.60 KB, patch)
2011-06-21 16:30 EDT, Olivier Thomann CLA
no flags Details | Diff
Complement (6.95 KB, patch)
2011-06-24 13:13 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed patch + regression test (4.33 KB, patch)
2011-06-28 05:40 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-06-15 14:41:52 EDT
BETA_JAVA7

IMethodBinding#getMethodDeclaration() should return the declaration of @PolymorphicSignature methods. That would match the general meaning of this method and is a similar exception as Object#getClass().
Comment 1 Markus Keller CLA 2011-06-16 05:44:26 EDT
Just to clarify: This applies to the resolved method bindings for references to the @PolymorphicSignature methods, e.g. on the last line here:

	MethodType mt; MethodHandle mh;
	MethodHandles.Lookup lookup = MethodHandles.lookup();
	mt = MethodType.methodType(String.class, char.class, char.class);
	mh = lookup.findVirtual(String.class, "replace", mt);
	s = (String) mh.invokeExact("daddy",'d','n');
Comment 2 Olivier Thomann CLA 2011-06-21 16:28:43 EDT
Released in BETA_JAVA7 branch.
Comment 3 Olivier Thomann CLA 2011-06-21 16:30:17 EDT
Created attachment 198363 [details]
Proposed fix + regression test

This includes the fix for bug 349487.
Comment 4 Markus Keller CLA 2011-06-22 08:13:39 EDT
The fix works fine. Code-wise, it would be cleaner to leave MethodBinding#getMethodDeclaration() unchanged, but override it in PolymorphicMethodBinding.

The Javadocs of IMethodBinding#getMethodDeclaration() and IMethod#getKey() also need to mention the special case. I'll fix this in BETA_JAVA7.

Filed bug 350039 for a problem with resolving the binding key of a polymorphic method reference.
Comment 5 Olivier Thomann CLA 2011-06-24 13:09:00 EDT
I will modify original() for PolymorphicMethodBinding to return the corresponding polymorphic method binding. This will leave org.eclipse.jdt.core.dom.MethodBinding.getMethodDeclaration() untouched.
Comment 6 Olivier Thomann CLA 2011-06-24 13:13:48 EDT
Created attachment 198553 [details]
Complement
Comment 7 Satyam Kandula CLA 2011-06-27 10:17:13 EDT
(In reply to comment #6)
> Created attachment 198553 [details]
> Complement
This patch fixes both bug 349683 and bug 349486. Thanks.
Comment 8 Satyam Kandula CLA 2011-06-27 22:14:40 EDT
oops.. With this change, polymorphic methods seems to be broken.:( There is a JVM exception while running the testcase and I see that the method declaration of invokeExact() in the generated code has Object rather than the correct type. I will restore the changes and add a test.
Comment 9 Satyam Kandula CLA 2011-06-28 05:40:29 EDT
Created attachment 198712 [details]
Proposed patch + regression test

I haven't reverted the changes but modified the code generation to take special care in case of Polymorphic methods. I have added a test for this also. 
Olivier, What do you think?
Comment 10 Olivier Thomann CLA 2011-06-28 08:40:34 EDT
Looks good. Thanks for catching this one.
Comment 11 Satyam Kandula CLA 2011-06-28 10:52:13 EDT
Thanks Olivier. Released on BETA_JAVA7 branch
Comment 12 Ayushman Jain CLA 2011-07-01 09:28:26 EDT
Verified using Eclipse Java 7 support(BETA) version v_B66