Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Re: [Bug 30439] spurious "circular dependency " error

Doug Orleans wrote:
> Jim.Hugunin@xxxxxxxx writes:
>  > before() throws IOException: fileOp() {
>  >     logStream = new FileOutputStream("log");
>  >     ...
>  > }
>  >
>  > after() throwing (IOException ioe): fileOp() {
>  >     handleException(ioe);
>  > }
>  >
>  > If the after is more precedent, then it will act as if it is
>  > "outside" of the before and any exceptions thrown by the "new
>  > FileOutputStream" call will be seen by the after throwing advice.
> 
> This seems wrong to me-- the join point that is throwing the exception
> is not in fileOp(), it's an advice execution join point.  (If it is in
> fileOp(), then why doesn't the before advice cause an infinite loop?)

The easiest way for me to think about precedence between multiple pieces of advice is to pretend that they are all converted to around advice.  In the case of around advice I think that the need for some sort of ordering is more clear, i.e.

around() throws IOException: fileOp() {
    logStream = new FileOutputStream("log");
    ...
    proceed();
}

around(): fileOp() {
    try { proceed() }
    catch (IOException ioe) { handleException(ioe); }
}

before and after advice can be considered syntactic sugar for around advice (except for a minor issue with checked exception typing that would require adding a 'rethrow' statement to Java).  

If you want a better description of what a join point is and what is and isn't a part of it you'll have to ask Gregor or Erik if they can provide one.

-Jim


Back to the top