Hooking an existing method in Java

前端 未结 5 1435
清歌不尽
清歌不尽 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:35

    You can rewrite the byte code of the methods, and in the process capture/change the local variables. It is not trivial. See some notes here.

    Maybe what you really want is a java debugger? You can connect a debugger to a remote process, add a breakpoint, and capture/change the local variables pretty easily using eclipse.

    What is the real problem you are trying to solve?

提交回复
热议问题