Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Modifying method signature

It's not possible to add a throws clause to a method:

http://dev.eclipse.org/viewcvs/indextech.cgi/%7Echeckout%7E/aspectj-home/doc/faq.html#q:methodsignatures

AspectJ only make binary-compatible changes.  Clients that had compiled
against that method would get a nasty surprise if it started to
throw unexpected checked exceptions at runtime.

However, you can see exceptions thrown from a method:

  after() throwing (Exception) : execution(void method()) {
     ...
  }

Or handle them:

  void around() : execution(void method()) {
     try {
        return proceed();
     } catch (Exception e) {
        handle(e);
     }
  }

Hope this helps -
Wes

> ------------Original Message------------
> From: Valerio Schiavoni <ervalerio@xxxxxxxxxx>
> To: aspectj-dev@xxxxxxxxxxx
> Date: Thu, Feb-3-2005 6:15 AM
> Subject: [aspectj-dev] Modifying method signature
>
> Hello everyone
>  i'm quite new to aop-aspectj, so please be kind :-)
> I'd like to add exception handling to a given method (see code below)
> 
> aspect A{
>     public void InterDeclaration.doNothing() throws Exception{};
> }
> public class InterDeclaration{
>     public void doNothing(){};
> }
> 
> and i get an error because doNothing() is already declared in the base 
> code.
> So, how can I obtain the same behaviour (if possible)?
> 
> thanks,
> Valerio
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 




Back to the top