This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Getting the method name that you are currently in. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting the method name that you are currently in." Watch "Getting the method name that you are currently in." New topic
Author

Getting the method name that you are currently in.

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Is there a way for an object to get the current method name that the object is in?
-Dale


By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
In JDK 1.4+ you can use Throwable.getStackTrace()


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
"the current method name that the object is in"
What does that mean? The OBJECT is not in any method, it is on the heap. There are one or more variables out there that hold a reference to that object.
Unless you are asking how to find out what method that a local variable is declared in that holds a reference to that object???
Or maybe you are asking at a particular moment in time what other object is manipulating this object in using what method??


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the method name that you are currently in.
 
Similar Threads
JNDI, xxx is already bound
[solved]warning message:" Accessing static method numbers" #7th floor
question on using JavaScript to set form value
Thread question
static methods-overridden