Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Runtime Exceptions in After Throws

2012/12/6 James Cook <james.cook@xxxxxxxxxxx>
    after() throwing(MyRuntimeException ex) : call (* *(..))
[...] 
Is this down to how AspectJ inspects for which methods are eligible? In other words is this expected behaviour for RuntimeException child classes?
Currently using 1.6.12  with Java 1.7_09.

AFAIK, AspectJ does not inspect the methods to find if they are eligible, it advises all the pointcuts that match. Especially in the case of a RuntimeException, it has no way to know if such an exception might be thrown in a method or in one of its called methods (and their called methods, etc.). You're not limited to the origin method of the exception as you don't always want to catch an exception right after the method where it's initially thrown, and AspectJ covers all these cases.

You need some way to restrict your pointcut.

Frank

Back to the top