Community
Participate
Working Groups
Created attachment 149513 [details] Amalgam of files to test aspectj advice. after(Object o) throwing(ExceptionType e) ... { ... } on a pointcut that matches methods with no throws clauses will not advise those methods when the ExceptionType is a checked exception. This, I believe, is an optimisation. However, it is perfectly possible that ExecptionType is checked but subclasses of ExceptionType are not. The prototypical example, is Exception. If throwing(Exception e) is part of the advice, then methods that do not declare throws types are NOT advised, even though they can validly throw (for example) RuntimeException. The RuntimeExceptions are therefore not caught by the after advice. The workaround is to specify throwing(Throwable t) and for the advice to filter out Exception exceptions. Since Throwable is not checked, this advises all methods whether they declare throws or not. I expect the after(Object o) throwing(ExceptionType e) {} to advise all methods in the pointcut that may possibly issue an exception that would be caught by catch(ExceptionType e) -- this includes subclasses of ExceptionType which may not be checked. Example attached. [I do not think this problem is operating system specific.]
for 1.6.7 find some time to work out why it is like this...
(In reply to comment #1) > for 1.6.7 find some time to work out why it is like this... I see we've drifted out to 1.6.10.
Nights are beginning to draw in....
Hi Andy, long time no comment.... :-) Hey, I've an idea, why not document this behaviour (carefully) and close this bug as 'working as designed'?
fixed !! I kept debating whether to change this behaviour or not. The change may impact some users exploiting the way it has been working up to now. However, I made the change and none of the AspectJ tests were affected. I was also struck particularly by the comment: > I expect the after(Object o) throwing(ExceptionType e) {} to advise all methods > in the pointcut that may possibly issue an exception that would be caught by > catch(ExceptionType e) I think that is right. So I've committed the change.
(In reply to comment #5) Thank you! We will now raise a bug in Virgo to track this change and when we upgrade aspectj we can simplify our code.