Can a method use reflection to find its' own name

example;

public void iDontCareAboutThisMethodName()

{

}

public void iWantToKnowThisMethodName()

{

// can I use reflection from inside this method and

// somehow determine the method name I am presently in

// something like

// System.out.println("I am now in method " + this.getClass().getCurrentMethodName());

}

[380 byte] By [wgoldmana] at [2007-11-26 17:09:31]
# 1
Why do you need to? If you're writing the code, you already know the name of the method - you typed it 3 lines earlier!
dannyyatesa at 2007-7-8 23:37:20 > top of Java-index,Core,Core APIs...
# 2
Not with reflection.You can create an exception, and somewhere in the stacktrace you should be able to find the method name. But I agree, I can't see why you would need to do that.
DrClapa at 2007-7-8 23:37:20 > top of Java-index,Core,Core APIs...