Hi Everyone,

This is my first email to this group so apologises if I violate any
expected etiquette rules. I have searched for an answer for the following
and have not discovered anything.

The problem I currently would like to understand is how AspectJ handles
"After Throws" aspects with a subclass of the Runtime Exceptions

I currently have this aspect.

public aspect MyExceptionAspect {

    declare precedence:MyExceptionAspect ,MyMainAspect;

    after() throwing(MyRuntimeException ex) : call (* *(..))  {

        // Do something with this...

        throw ex;
    }
}

N.B MyRuntimeException extends RuntimeException

What I discovered is that when doing a compile time weave that any method
that contains anything that throws a RuntimeException or subclass of would
be subjected to that weave - Not just my methods that would throw
MyRuntimeException.

Is this down to how AspectJ inspects for which methods are eligible? In
other words is this expected behaviour for RuntimeException child classes?

Currently using 1.6.12  with Java 1.7_09.

On a side note, when I decompiled a weaved class I did find this:

public void aMethod() {

   try {
   } catch (MyRuntimeException myRuntimeException) {
      MyRuntimeException
.aspectOf().ajc$afterThrowing$com_me_MyExceptionAspect$1$e9b72fa2(myRuntimeException);
throw myRuntimeException;
   }

   myObject.methodThatThrowsARuntimeException();
}

where as the original method is:

public void aMethod() {

   myObject.methodThatThrowsARuntimeException();
}

Kindest Regards

James
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to