Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349487 - [1.7] IMethodBinding#getJavaElement() returns inexistent element for @PolymorphicSignature methods
Summary: [1.7] IMethodBinding#getJavaElement() returns inexistent element for @Polymor...
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:39 EDT by Markus Keller CLA
Modified: 2011-08-05 02:54 EDT (History)
3 users (show)

See Also:


Attachments

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:39:02 EDT
BETA_JAVA7

IMethodBinding#getJavaElement() returns inexistent elements for @PolymorphicSignature methods. Can be seen in the ASTView with the "Usage examples" from the Javadoc of java.lang.invoke.MethodHandle.

The Object#getClass() method from 1.5 is a similar case. There, the return type of invocations doesn't match the return type of the method declaration. IMethodBinding#getJavaElement() there returns IMethods that are equal to each other and to the declaration, although they have different return types.

With PolymorphicSignature methods, also the argument types can vary. I guess it would be best here to always return an IMethod that matches the signature of the declaration.
Comment 1 Olivier Thomann CLA 2011-06-15 14:45:11 EDT
(In reply to comment #0)
> With PolymorphicSignature methods, also the argument types can vary. I guess it
> would be best here to always return an IMethod that matches the signature of
> the declaration.
So two invokeExact(..) would return the same IMethod ?
Comment 2 Markus Keller CLA 2011-06-15 14:54:58 EDT
> So two invokeExact(..) would return the same IMethod ?

Yes. When bug 349488 is fixed, I'd expect the same as getMethodDeclaration().getJavaElement().
Comment 3 Olivier Thomann CLA 2011-06-15 16:01:03 EDT
What do you expect for polymorphic methods for the parameter types ? The actual parameter types or Object[] ?
Same question for the return type ?
Comment 4 Markus Keller CLA 2011-06-16 05:32:37 EDT
I don't think we should have multiple IMethods in the model that exist and are equal but don't have the same parameter types.

The Java element model is mainly a declaration model, with only 2 exceptions so far:
- there can be multiple versions of Object#getClass() that differ in the return types
- resolved ITypes and IMethods can have different keys (depending on the actual type arguments), but their signatures still match the declaration

For the declaration and for references to the 2 methods, I'd expect
- return type Object
- parameter type Object[]
- varargs flag


For references to the methods, IMethodBinding#getJavaElement() and codeSelect(..) should return IMethods whose isResolved() is true and whose getKey() returns the binding key of the method binding of the corresponding MethodInvocation node.
Comment 5 Satyam Kandula CLA 2011-06-21 01:25:27 EDT
I believe bug 349486 fails for the same reason
Comment 6 Olivier Thomann CLA 2011-06-21 16:29:26 EDT
Released in BETA_JAVA7 branch.
Comment 7 Ayushman Jain CLA 2011-07-01 09:28:16 EDT
Verified using Eclipse Java 7 support(BETA) version v_B66