Home > Net >  How to find all callers of all methods in a specified class?
How to find all callers of all methods in a specified class?

Time:09-21

I'm looking for a way to output into file all methods, that are calling all methods in a specified class. I see that I could use ASM for this, but I cannot figure it out.

Example: class A has methods aA, bA, cA. class B calls methods aB -> aA, bB -> bA, cB -> cA.

I want to output "aB -> aA, bB -> bA, cB -> cA" into file.

My main goal is to trace all these calls from ExceptionFactory to service layer, and then output which service methods can throw specific exceptions.

The most suitable way for me would be, that it would run as a test, the file would be created during test phase.

EDIT: I actually don't know what class B is, I need to find out which class/classes calls class A.

CodePudding user response:

You can achieve something like above in your question by making use of JavaAssist library as given here : enter image description here

  • Related