Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get method's caller?

807603Dec 19 2007 — edited Dec 20 2007
Hello,

How to get caller of the method (as object, which called it, or as object of the same class) ?
For instance, I can use
            Throwable tracer = new Throwable();
            tracer.fillInStackTrace();
and then analize this stack trace, but in this case I have to use Java Reflection to make object of the class in stack (because stack contains strings). Is there any other way to do it?
Which stack is used by IDE's debuggers, do they use the same StackTraceElement and JavaReflection?

Thanks in advance,
Maxym
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2008
Added on Dec 19 2007
19 comments
572 views