| Author |
Method trace
|
Kalai Selvan
Ranch Hand
Joined: Jul 07, 2004
Posts: 79
|
|
Hi All, Is there any way by which I can find from which method a particular method has been called. Thanks in advance.
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
|
Get a stack trace from Thread.getStackTrace(). Examine the StackTraceElement objects, to see how you got to where you are.
|
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
|
You don't say why you want this information. If it's just for tracing, diagnostics or maybe assertion, that's fine. If you're thinking of writing logic that depends on who called the method, think again - that's appalling design.
|
 |
Arun Kumar
Ranch Hand
Joined: Jan 21, 2005
Posts: 127
|
|
If you are using Rad as your IDE it has an option by right clicking on the particular method you can select the option Open Call Hierarchy I think Latest version of Eclipse also supports this option Even in older versions you can right click a method and search for references that would display all methods that refers to this particular method
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
|
Arun, those are things you can do while you're writing the program, but the original poster wants a programmatic approach, that can be done during run-time.
|
 |
 |
|
|
subject: Method trace
|
|
|