开发者

Modifying existing java class behavior with aspectj?

I want to add some debugging code to an already compiled java class while not touching the original class. I'm thinking of using AspectJ, but I just want to know if it is possible, and if so how?

Example: class A contains void main() which does stuff an开发者_如何学Cd calls method sum(). aspect B adds println() to before A.sum() I want to run class A with aspect B's modification without editing A in any way.


It's possible to do this without touching existing java class (either binary or source), using load-time weaving (LTW).

Please see the official documentation on LTW: http://www.eclipse.org/aspectj/doc/released/devguide/ltw.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜