java question to decide who called this method -


i have following scenario both testone() , testtwo calls same callme() method.

how decide inside callme() method called callme().  public void testone(){     callme(); }  public void testtwo(){     callme(); }  public void callme(){     system.out.println("i called following method."+methodname);       }   sort of appreciated. 

any solution has generating stacktrace , looking @ second frame 1 going lead pain - doing bypassing idea of passing function needs in order function it's work.

if need name of caller method, just pass parameter. if need other piece of data decide in callme() method, pass (as boolean, int, etc.).

it confuse other developers working on code why callme() has secret parameters.

public void testone(){     callme("testone"); }  public void testtwo(){     callme("testtwo"); }  public void callme(string methodname){     system.out.println("i called following method."+methodname);      } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -