Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » isSubsignature() of method bindings returns false for calls of methods with type parameter
isSubsignature() of method bindings returns false for calls of methods with type parameter [message #1715145] Thu, 19 November 2015 15:25 Go to next message
Johannes Dorn is currently offline Johannes DornFriend
Messages: 61
Registered: June 2013
Member
Scenario

interface IMyInterface {
   <T> T m(T arg);
}

class Example {

   void m(IMyInterface arg0, Example arg1) { 
      arg0.m(arg1);
   }

}


I have the method binding for the invocation of m:
public abstract Example m(Example)

and the method binding for the declaration in IMyInterface:
public abstract T m(T)

I believe the former should be a subsignature of the latter. However, isSubSignature() returns false.

If i rewrite the scenario slightly by moving the type parameter to the class level, isSubsignature() returns true:

interface IMyInterface<T> {
   T m(T arg);
}

class Example {

   void m(IMyInterface arg0, Example arg1) { 
      arg0.m(arg1);
   }

}


Re: isSubsignature() of method bindings returns false for calls of methods with type parameter [message #1715149 is a reply to message #1715145] Thu, 19 November 2015 15:47 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Please try org.eclipse.jdt.core.dom.IMethodBinding.getMethodDeclaration() on the binding obtained from the invocation. That should give you the exact same binding as you get from the interface (and obviously, isSubsignature() should answer true when comparing).

A binding from the invocation of a generic method is expected to be more specific than the generic method itself.
Makes sense?
Stephan
Re: isSubsignature() of method bindings returns false for calls of methods with type parameter [message #1715153 is a reply to message #1715149] Thu, 19 November 2015 16:22 Go to previous messageGo to next message
Johannes Dorn is currently offline Johannes DornFriend
Messages: 61
Registered: June 2013
Member
Thank you very much! That seems to solve my problem.

One further question, though: can getMethodDeclaration() return null or is a non-null binding guaranteed?
Re: isSubsignature() of method bindings returns false for calls of methods with type parameter [message #1715155 is a reply to message #1715153] Thu, 19 November 2015 16:30 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I do see null returns (e.g., in case of compile errors, missing types - that kind of story)...
Previous Topic:How to run Eclipse on Windows 7 64-bit
Next Topic:Seeing breakpoints
Goto Forum:
  


Current Time: Fri Apr 26 04:10:22 GMT 2024

Powered by FUDForum. Page generated in 0.03364 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top