Skip to main content



      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 11:56 Go to next message
Eclipse UserFriend
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 16:26 Go to previous messageGo to next message
Eclipse UserFriend
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 09:47 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 05:24:23 EDT 2025

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

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

Back to the top