[[tracing:intro|Intro]]
[[tracing:ex1|Ex1]]
[[tracing:ex2|Ex2]]
[[tracing:ex3|Ex3]]
====== Tracing: Exposing the receiver ======
**Task:** Pass the suite ''tests.ReceiverTraceOutput''.
Write a similar aspect to log the execution of all public methods in the ''figures'' package. This time, include the string representation of the receiver as well as the join point. The log lines should follow this pattern:
thisJoinPointInfo at targetObject
Use the primitive pointcut ''target''.
With your aspect you should be able to pass the tests of suite ''tests.ReceiverTraceOutput''.
Do you receive ''StackOverflowError''s? This is a common pitfall in AspectJ (see [[http://www.eclipse.org/aspectj/doc/released/faq.html#q:infiniterecursion|the FAQ entry]]). An infinite loop occurs because inside of the control-flow of the advice body is a new matching join point, which causes a new invocation of the advice body, which causes a new join point and so on.
To discover the root of the infinite loop, consider the difference between this advice body and the one from the previous exercise. Another clue is in the "official" description of [[http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#39990|Java String Concatenation]]. Solve the problem by making the pointcut more restrictive: it should exclude join points in the control flow of the advice execution.
----
After you have completed the exercise, remove your aspect from the build path; then continue with [[tracing:ex3|Exercise 3]].