[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Re: Method-call join point throws restriction
|
>Michael Moser asked (on news:eclipse.technology.ajdt) why advice on method
=
>call join points needs its exceptions to conform to the throws clause of
the
>method signature of the called method. It makes sense to me to lift this =
>restriction, and to allow method-call join points to throw any throwable
(and
>follow the normal flow analysis for checked exceptions in Java). Naturally
>method execution join points need this restriction (so the resulting
methods
>don't throw an undeclared checked exception)
Unfortunately call join points are not tied to single enclosing execution
join point where throwing a particular checked exception is permitted.
Consider the following example: the main() method is OK but when we add
"anotherMain()", which has no throws clause, we would get a compilation
error. The suggested enhancement could prevent program evolution as changes
in the base code might cause existing aspects to break.
public class HelloWorld {
public static void method () {
}
public static void main(String[] args) throws Exception {
method();
}
public static void anotherMain(String[] args) {
method();
}
}
public aspect Aspect {
pointcut method () :
call(* method(..)) && withincode(* main(String[]));
before () throws IOException : method () {
throw new IOException(thisJoinPointStaticPart
.getSignature().toString());
}
}
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/