Community
Participate
Working Groups
It is clear why arbitrary checked exceptions cannot be thrown from advice. However, the restriction that only checked exceptions declared on the point cut may be thrown is sometimes too stringent. A point cut may match many join points and some may allow different checked exceptions. In fact the checked exceptions might not even be known at the time the aspect is written so including them in the point cut is not an option. Ramnivas Laddad <ramnivas@aspectivity.com> and I came up with similar proposals for how to support throwing checked exceptions compatible with the join point (but not necessarily the point cut) which I present here. Imagine the following advice: around() : somePointCut() { try { // do something proceed(); } catch (Exception e) { rethrow e; } } The "rethrow" keyword would behave like "throw" except it would check against joinPointStaticPart and if the exception being rethrown is a checked exception incompatible with the join point, it is first wrapped in an unchecked one (perhaps "IncompatibleRethrownException"). A user of the current version of AspectJ can accomplish this functionality but it requires manually checking the joinPointStaticPart and then using JDK loopholes to throw a checked exception as an unchecked one. More discussion can be found on the aspectj-dev thread in the URL of this enhancement request.
unsetting the target field which is currently set for something already released