Bug 240608 - Allow checked exceptions which are declared on the join point but not on the point cut to be thrown from advice
Summary: Allow checked exceptions which are declared on the join point but not on the ...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Library (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 20 votes (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL: http://dev.eclipse.org/mhonarc/lists/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-13 18:36 EDT by Nobody - feel free to take it CLA
Modified: 2013-06-24 11:05 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nobody - feel free to take it CLA 2008-07-13 18:36:38 EDT
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.
Comment 1 Andrew Clement CLA 2013-06-24 11:05:44 EDT
unsetting the target field which is currently set for something already released