Hooking an existing method in Java

前端 未结 5 1473
清歌不尽
清歌不尽 2021-02-19 14:08

I want to hook the method System.out.print in Java and have the ability to read/change the variables used in the method before the part of the method is called that actually add

5条回答
  •  佛祖请我去吃肉
    2021-02-19 14:22

    Have a look at this link.

    He sneakily defines a static anonymous class so that System.out points to something different, and therefore print and println will route through that object.

提交回复
热议问题