This content has been marked as final. Show 3 replies
You can monitor the method entry and exit using jvmti.
This will degrade the performance. Other option would be to use btrace which is based on byte code instrumentation.
Thanks for your reply. I am already looking into JVMTI. I will try the other one too. But I want to make my question clear. I don't need to monitor the entry and exit to a method. I want to know which methods of an object [say objA] are being called and the methods called by this object[objA]. I just need to log these method calls.
None of them are easy alternatives. Sure, JVMTI will solve your purpose, but if speed is not an issue, I would suggest an "all java" alternative using spring interceptors. They will use byte code instrumentation at runtime (invisible to you) but what you want to do will literally be a piece of cake with spring interceptors. Ofcourse, your objects will all have to be spring beans.
Look into some spring / AOP tutorials on how to do this. A simple google search and you will have what you need.