How do I get a list of Methods called from a Class

2019-02-26 04:36发布

I am using Eclipse IDE for my Java project. I need a list of methods which are being called from a particular class i.e. I need to see a list of all the methods which are being called from a class but not declared in that. I am looking for some option which might be there in Eclipse already. I am not willing to write a code for this (that will be my last choice).

Let me explain using this example -

public class ABC {

 public void methodA {
  System.out.println("In methodA");
  BCD bcd = new BCD();
  bcd.callMethodAA(); // defined in class BCD
 }

 public void methodB {
  System.out.println("In methodB");
  CDE cde = new CDE();
  cde.callMethodBB(); // defined in class CDE
 }
}

I want an option which will show me - From Class ABC we are calling - a) callMethodAA b) callMethodBB

7条回答
狗以群分
2楼-- · 2019-02-26 05:10

If it is at runtime, you could use a Dynamic Proxy. The dynamic proxy is called before the method invocations of your class and you can log somewhere (to another class, or a file or whatever) which methods have been called.

查看更多
登录 后发表回答