jeudi 25 mai 2017

How to determine which method called a method in java? [duplicate]

This question already has an answer here:

Suppose I have below code snippet:

class A{
 // Something made below line to execute
 new B().foo();
}

class B{
void foo(){
  new C().bar();
    }
}

class C{
void bar(){
// Log name 'foo' as foo method called bar
    }
}

How can I log method name in bar using some APIs to determine the caller method?





Aucun commentaire:

Enregistrer un commentaire