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

Bug 350039

Summary: [1.7] ASTParser#createASTs(..) doesn't resolve IMethodBinding for @PolymorphicSignature method reference
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, raksha.vasisht
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression test
markus.kell.r: review-
Proposed fix + regression test none

Description Markus Keller CLA 2011-06-22 08:11:15 EDT
BETA_JAVA7

Have:

	void bar() throws Throwable {
	    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);
	    String s = (String) mh.invokeExact("daddy",'d','n');
	}

The IMethodBinding for reference

    mh.invokeExact("daddy",'d','n')

has key

    Ljava/lang/invoke/MethodHandle;.invokeExact(Ljava/lang/String;CC)Ljava/lang/String;|Ljava/lang/Throwable;

Passing this key to ASTParser#createASTs(..) doesn't resolve the original IMethodBinding, but only resolves an ITypeBinding for class MethodHandle. Works fine for the method declaration.

To reproduce, you can choose "Parse Binding from Key..." from the ASTView's view menu.
Comment 1 Olivier Thomann CLA 2011-06-24 13:40:52 EDT
Created attachment 198554 [details]
Proposed fix + regression test
Comment 2 Olivier Thomann CLA 2011-06-24 13:41:50 EDT
For polymorphic method, we should not try to match parameter types.
Markus, please give it a try.
Comment 3 Markus Keller CLA 2011-06-24 14:56:58 EDT
Comment on attachment 198554 [details]
Proposed fix + regression test

Hmm, that gives me the binding for the declaration, not for the given key. Add this to the test:

		assertEquals("Wrong key", key, bindings[0].getKey());
Comment 4 Olivier Thomann CLA 2011-06-27 12:56:52 EDT
Created attachment 198666 [details]
Proposed fix + regression test

Updated patch. More complex code to create the right binding.
Markus, let me know if this looks better for you.
Comment 5 Markus Keller CLA 2011-06-27 13:37:09 EDT
Looks good, thanks.
Comment 6 Olivier Thomann CLA 2011-06-27 15:33:19 EDT
Released in BETA_JAVA7 branch
Comment 7 Raksha Vasisht CLA 2011-07-20 06:29:20 EDT
Verified.