overloaded-advices example step by step. This example comes bundled with JBoss AOP release, so all you need to do is to download the 2.0.0.GA release and start following the next steps.First, create a project for the
overloaded-advices tutorial example using Eclipse (the URL location is jboss-aop-2.0.0.GA/docs/aspect-framework/examples/overloaded-advices) and solve classpath issues by adding the JBoss AOP jars to the classpath (just include the jars of the jboss-aop-2.0.0.GA/lib directory).Now, add a breakpoint to the
Driver class, line 29, where there is a call to POJO constructor, the first joinpoint of the example that will be intercepted: 
Configure a Java Application execution to run the
Driver class, setting the AOP arguments as has been showed in the first part of this tutorial.- Start debugging this application.
- Once Eclipse stops at line 29, press
F5to enter the constructor execution joinpoint. This is what you are going to see: - You see that the previous step resulted in a stack trace that shows a wrapper method belonging to the
POJOclass:POJO.POJO_new_$aop(), followed by the wrapper that is our focus of interest, the one belonging to theAdvisorclass:POJO$POJOAdvisor.POJOAdvisor_new_$aop().
However, the top line of the stack is one of the “noises over the line” mentioned in the previous tutorial part. That line is a call to aConstructorInfomethod that returns some a sort of concurrency lock. So, pressF7to return to theAdvisorwrapper method. Once you do this, you should see the stack trace below: - Whenever you are in the
Advisorwrapper method, you should pressF5. This is what we get once we pressF5:
- Oh no! Another “noise”. This time, more code handling locks. Now you know what to do. Press
F7, return to the wrapper method, and pressF5on this wrapper until you enter a new block of code. Continue this process until you have finally entered the Joinpoint class.
These are the “noises” you will run into during this process:


Note that the second “noise” (ConstructorInfo.hasAdvices()) will appear twice in a row.
After step returning those “noise” elements withF7, Eclipse finally enters the first advice execution:
- Once you get to the advice, debug it as you would normally. As this is a just tutorial, we are going to press
F6until we return to theJoinpointclass:
- Back to the
JoinPointclass. PressF5until you find the next advice. Before getting there, you are going to run into another couple of “noise” elements:
On the screen above, you see an info call at the top of the stack. As mentioned previously, this is something you should skip withF7. Right below it in the stack, there are three calls to constructors (<init>methods). Again, we have mentioned previously that calls to constructors should be skipped withF7. Skipping them and then pressingF5will take you to the next advice:
- You should debug this advice as you did in step 6, with
F6. There is one line, however, that you must treat differently and pressF5: line 39 ofJoinPointAspect, containing the statementreturn invocation.invokeNext();
This line, as you should know, is going to invoke the next around advice. If there are no around advice, it is going to call the joinpoint itself. So, if you want to debug thePOJOconstructor execution, you must enter theinvocation.invokeNext()call. After pressingF5in this line, you will see the following stack:
- At this point, you have reached the joinpoint being intercepted. Whether it is a method or constructor, you can debug it as if this was a normal Java application. If it is a field set or a field get, you are not going to be able of debugging it though. But you can check the new value of the field after a field set joinpoint once you get back to your normal application at step 13.
In this case, the joinpoint is a default constructor, so there are no lines to debug at all. Just pressF6to return to the previous item in the stack:
- So, we are back to the
Joinpointclass. Now, you should pressF5again following the tips given in step 5. Doing so will take us to the last advice:
- Repeat step 6 now, pressing
F6to return to theJoinpointclass:
- Pressing
F5now does not take us to the next advice,as all advice have already run. It takes us back to the advisor wrapper method.
- You are done! Just press
F7twice to exit both wrappers and go back to the driver class. Now you can continue debugging. Try to enter the next joinpoints of theoverloaded-advicesexample to see the other advice running! Remember that you must pressF5on field read and field write joinpoints, in order to enter their wrapper method code.


Next Steps
Once you have walked-through the steps to debug the
overloaded-advices example, you are ready to debug any other JBoss AOP application you like. Try doing so using a different JBoss AOP tutorial, or just try debugging your own JBoss AOP application.The next time you need to debug an application that uses JBoss AOP, I hope it is going to be easier for you to track bugs down with the tips we have presented in this tutorial. Good luck!











