Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: Exception handling framework

I do have one remaining problem: every method in the application that
could throw an exception should have a "throws ...Exception" in its
declaration, or there should be a try-catch block. The catch should than
be left empty, as the handling is done by the aspect. I do not see any
sollution to this problem.

The idea of a exception handling framework looks a good one to me. The issue of throws clauses and checked exceptions versus AOP has also been troubling me for some time. There is some merit in the motivation behind checked exceptions - to ensure program robustness and reliability in the presence of unpredictable occurrences from the environment and other software components. The problem is that Java's mechanism of tackling this enforces code tangling, exactly what AOP is meant to avoid. I think there is a certain tension between checked exceptions and AOP. Aspects have the potential to modularise the issuing / handling of exceptions just like any other crosscutting concern. It's just that the "throws Exception" rule keeps getting in the way. I find it a bit funny that AOP's most widely used language includes a mechanism that enforces a crosscutting concern into its code. IMHO the AspectJ team should one of these days tackle this problem. The ajc compiler could stop generating error messages due to missing try-catch blocks. ajc could even provide a switch to re-activate the enforced try-catch (perhaps for mission-critical software), just like javac does with the assert statement. After all, AspectJ already enables several things that are forbidden by straight Java - privileged aspects are one good example. Perhaps AspectJ could provide something along these lines in order to avoid all those try-catch blocks.
--
Miguel J. T. Pessoa Monteiro
Ph.D. student Minho University, Portugal
eMail: mmonteiro@xxxxxxxxxxxx
URL: http://gec.di.uminho.pt/mpm/


Back to the top