I want to retrieve the calling method where a specific method is called.
Example :
The method I consider :
public void methodA(int a, int b){...}
is called in a test method and also in the program itself
@Test
public void testMethodA(
... some code...
objectClassA.methodA(x,y);
)}
Class B {
...
public void methodB(){
objectClassA.methodA(x,y);
}
}
What I want to obtain somehow is the inside or at least the signature of testMethodA and methodB
To do that I thought AspectJ could help me, so I looked into that and ended up writing this poincut pointcut pcmethodA(): execution(* A.methodA(..) );
and my advice looked something like this
before(): pcmethodA() {
System.out.println("[AspectJ] Entering " + thisJoinPoint);
System.out.println("[AspectJ] Signature " + thisJoinPoint.getSignature());
System.out.println("[AspectJ] SourceLocation "+ thisJoinPoint.getSourceLocation());
But this returns
[AspectJ] Entering execution(void com.example.somePackage.A.methodA(int, int)
[AspectJ] Signature com.example.somePackage.A.methodA(int, int)
[AspectJ] SourceLocation A.java:25 /** Line number of the methodA in the file **/
It is my first time using AspectJ , is there any object or way to retreive the calling method of my found joinpoints? testMethodA and methodB
Thanks