Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding
Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding [message #1720603] Tue, 19 January 2016 16:56 Go to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi,

I am currently struggling with a utility method that, given an IMethodBinding returns all ITypeBindings in the hierarchy which declare the method in question.

In particular, I want my method to return both Interface and Object when called with the IMethodBinding for Interface.toString().

  interface Interface {
    String toString();
  }

Alas, I can't find a way to get at the ITypeBinding for java.lang.Object starting from the IMethodBinding for Interface.toString(), as ITypeBinding.getSuperclass() returns null for interfaces.

Is there a way that does not use AST.resolveWellKnownType("java.lang.Object") to accomplish this? I'd rather not have AST in my methods signature, as I would like to stay solely in the realm of IBindings..

Also, repeated calls to resolveWellKnownType look slowish (but I haven't benchmarked this yet).
Re: Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding [message #1722450 is a reply to message #1720603] Thu, 04 February 2016 21:26 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I believe AST.resolveWellKnownType("java.lang.Object") should be OK, as it basically goes through the same internal lookup - resolver.getTypeBInding() - that is also used in TypeBinding.getSuperclass() et al.
Plus, you're not really using AST functionality here, as you use the AST instance only as an interface to access the internal resolver.

Re: Getting the java.lang.Object ITypeBinding from an interface method's IMethodBinding [message #1722717 is a reply to message #1722450] Mon, 08 February 2016 14:47 Go to previous message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Quote:
I believe AST.resolveWellKnownType("java.lang.Object") should be OK, as it basically goes through the same internal lookup - resolver.getTypeBInding() - that is also used in TypeBinding.getSuperclass() et al..


Thanks, Stephan for confirming that this is the way to go. Too bad that there is no ITypeBinding.resolveWellKnownType, so one has to pass ASTs around further than actually needed, deep into helper methods which should really be able to operate with bindings alone.
Previous Topic:Quality and future of eclipse as IDE (for Java)
Next Topic:Installing of the eclipse programme.
Goto Forum:
  


Current Time: Tue Apr 16 20:32:06 GMT 2024

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

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

Back to the top