How to instrument java methods?

前端 未结 5 683
不思量自难忘°
不思量自难忘° 2020-12-09 22:15

I want to write a simple java agent which can print the name of a method called by the java program instrumented.

For example, my java program I want to instrument

5条回答
  •  离开以前
    2020-12-09 22:50

    I do not think it is easy.

    The only option I can think of would be implementing a class loader and replacing the original classes with stubs created by you (Hibernate / JPA does something like that for lazy loading). The stubs would perform the operation you require and then call the original classes to perform the work. It would mean a heavy burden (reflection calls are not cheap).

提交回复
热议问题