I want to recover in Java the instance of the caller. Here is my code
class A {
void methodA() {
B b = new B();
A a = b.methodB(); //needs to be the same instance ie "this"
}
}
class B {
A methodB() {
//Here the code (with reflection) I need
A a = getPreviousInstanceCaller();
return A
}
}
Does it exist in Java a way to do that ? Maybe with reflection ?