Re: Dynamic Method Invocation (specific line)
Lew wrote:
ash wrote:
Hello All,
I am using Java Reflection API to dynamically invoke methods from
classes. But i am trying to figure out a way to invoke specific lines
within methods. Is there a way around this problem ?
No. Why do you call it a "problem"?
More to the point, why are you trying to break the fundamental
object-oriented nature of Java in the first place? It sounds like some
other language would suit your purposes better.
The Java approach would be NOT to use reflection but to design your
code. If you have a few lines of code you want to execute separately,
they belong in a separate method in the first place.
Reflection is no substitute for a good design.
Again, I don't think we will come to a satisfactory answer unless ash
tells us the purpose of these proposed operations.
If Java really is the best language choice for ash's problem, then this
newsgroup's collective knowledge will include good ways of implementing
what ash wants in Java. If Java is not the best language choice, someone
here will be familiar with each language that would be better.
As it is, we are handicapped by not knowing *why* ash wants to do things
that do not really fit with how Java is supposed to be used.
Patricia