开发者

aspectj-maven-compiler plugin : how to weave JRE System.*?

I'm trying to detect where a mysterious System.gc() comes from, so I'm hoping to create a pointcut on all calls to System.gc()

the doc describes how to weave existing jars and e开发者_如何学运维xisting dirs, but how do I weave the JDK itself ?

Thanks a lot


You can weave rt.jar beforehand and replace it in your JDK/JRE. Note that load time weaving will not work as the Javaagent does not have access to bootstrap classloader.

However, quick search reveals that there is only one place in the whole JDK (Sun 1.6.0_26) that calls System.gc() explicitly:

java.nio.Bits#reserveMemory

Maybe you can simply attach a debugger and put a breakpoint on gc() method?

That being said you can use call() advice as opposed to execution() which will weave calling client code rather than target method. So you only have to weave your code and all libraries rather than the JDK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜