How do I trace methods?

Hi All,

I'm working on an vast application. I want to know the list of methods that's called before a particular method is called. Something like Exception.printStackTrace() method. During runtime, when a particular method is called, I want to list down all the methods that's called in order before this particular method is called.

Your help is appreciated.

Best Regards,

Ali.

[412 byte] By [ASIA_Alia] at [2007-11-26 19:06:02]
# 1
don't crosspost
jverda at 2007-7-9 20:56:54 > top of Java-index,Java Essentials,New To Java...
# 2
> don't crosspostI never post when I'm cross. Which reminds me of the line from Groundhog Day when Bill Murray steals the groundhog "Don't drive angry!"
floundera at 2007-7-9 20:56:54 > top of Java-index,Java Essentials,New To Java...
# 3

Well, it's always been possible to just say "new Exception().printStackTrace()." The object doesn't need to be thrown to contain a useful stack trace.

But in recent Java versions, you can call dumpStack() on a Thread to print a trace, and you can also call Thread.getStackTrace() to get an array of StackTraceElement objects, which describe each stack frame nicely. Use the static method Thread.currentThread() to get the currently executing Thread. and call dumpStackTrace()

Thread.currentThread().dumpStackTrace()

arunmp25a at 2007-7-9 20:56:54 > top of Java-index,Java Essentials,New To Java...