|Using Method Invocation Visitor [message #554922]
||Tue, 24 August 2010 14:15
| Niranjani S
Registered: August 2010
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=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,
Powered by FUDForum
. Page generated in 0.02314 seconds