Community
Participate
Working Groups
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().
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');
Released in BETA_JAVA7 branch.
Created attachment 198363 [details] Proposed fix + regression test This includes the fix for bug 349487.
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.
I will modify original() for PolymorphicMethodBinding to return the corresponding polymorphic method binding. This will leave org.eclipse.jdt.core.dom.MethodBinding.getMethodDeclaration() untouched.
Created attachment 198553 [details] Complement
(In reply to comment #6) > Created attachment 198553 [details] > Complement This patch fixes both bug 349683 and bug 349486. Thanks.
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.
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?
Looks good. Thanks for catching this one.
Thanks Olivier. Released on BETA_JAVA7 branch
Verified using Eclipse Java 7 support(BETA) version v_B66