Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Using Method Invocation Visitor(Java AST visitor pattern)
Using Method Invocation Visitor [message #554922] Tue, 24 August 2010 14:15 Go to next message
Eclipse UserFriend
Hi all,
I wrote this code to trace all the methods called by a member method in a class using the MethodInvocation visitor pattern. When I call resolvebinding, I'm able to differentiate overloaded methods by checking the parameter type and/or number of parameters. But I'm not able to trace overridden methods.

Say for example, there are two classes A and B where A is the superclass and B is the subclass. Then, I have:
A a;
A a=new B();
Suppose there is a method, say, setVal in A which is overridden in B.

Then the call a.setVal() will call B's setVal() but the Method Invocation Visitor pattern resolves it to A's setVal(). Can this be sorted out by some other way?? Or since java uses late binding this resloving can be done at run-time only???

Thanks in advance,

Niranjani S



Re: Using Method Invocation Visitor [message #554987 is a reply to message #554922] Wed, 25 August 2010 02:07 Go to previous messageGo to next message
Eclipse UserFriend
Yes, it will not be possible to figure out the exact binding at compile time. However, you can find out the possible bindings by getting the subtypes of A and then checking if the methods are overriden in the subtype.
BTW, try to use - SearchEngine.searchDeclarationsOfSentMessages(). This is probably what you are writing.
Re: Using Method Invocation Visitor [message #846919 is a reply to message #554987] Mon, 16 April 2012 17:50 Go to previous message
Eclipse UserFriend
Method overriding can be detected using IMethodBinding.overrides(IMethodBinding)

Thanks a lot,
Niranjani S
Previous Topic:Create a new xml file from java code
Next Topic:ECLIPSE doesn't start UBUNTU 11.10
Goto Forum:
  


Current Time: Wed Jul 09 09:17:53 EDT 2025

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

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

Back to the top