How to capture the parameters of System.out.println() in AspectJ's aspect and display in pointcut?

前端 未结 2 1711
[愿得一人]
[愿得一人] 2021-01-21 07:21

I am very new to AspectJ...just started to learn. Till now i am able to get the parameters of user defined method in my aspect and print the captured parameter in my pointcut.

相关标签:
2条回答
  • 2021-01-21 07:39

    catch of method calls from JRE is not so easy.

    is easier to learn aspectj when you try to catch your own methods. Define your own println method perhaps in HelloClass and try again.

    for work with aspectj and jre classes you need to recompile jre classes with aspectj compiler.

    http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg09350.html

    0 讨论(0)
  • 2021-01-21 07:55

    I was shocked still .. 2 days after posting,no one answered my this question... but its fine i have found a solution and realized where i was wrong. it was the mistake in my signature of println method().

    This is the correct signature of println:

     void around(String str) : 
        call(void java.io.PrintStream.println(String)) && args(str)
    

    and it worked fine for me . .

    0 讨论(0)
提交回复
热议问题