Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] advice/exception

Advice cannot throw any checked exception that the join point itself
is not declared to throw.  This is stated in the second "advice and checked exceptions" of the programming guide, semantics appendix:

http://dev.eclipse.org/viewcvs/indextech.cgi/%7Echeckout%7E/aspectj-home/doc/progguide/semantics-advice.html#d0e5851

Anything less would violate a java compiler's responsibility to perform exception-checking.   

You can either throw an unchecked exception, or restrict the join points to those that throw your exception, e.g.,
  
  execution(public * KontoAsp.ueberweisen(..) throws ProcessException ) 

Wes

> ------------Original Message------------
> From: franzr <reitinger.franz@xxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Tue, Jul-13-2004 3:04 PM
> Subject: [aspectj-users] advice/exception
>
> Hi listeners,
> 
> I try to write an aspect which is responsible for checking parameters 
> of 
> several methodes. The param-check is done within an advice (before); if 
> the 
> check detects an invalid parameter an exception should be thrown to 
> inform 
> the caller of this bad parameter.
> 
> However, it is not possible to compile this aspect because the compiler 
> 
> finishes its work with an "Unhandled exception type ...".
> 
> Example:
> 
> before (KontoAsp  konto) :  execution(  public  * KontoAsp.ueberweisen( 
> ..)) 
> && args(..,  konto)  {
> 	.......
> 		if (konto == null)
> 			throw new except.ProcessException(" ....");
> 			
> 	.......
> 	}
> 
> 
> What I'm doing wrong?
> Why does the compiler complains about an unhandled exception without 
> knowing 
> the caller. It's the duty of the caller to manage exceptions.
> 
> ThanX
> franzR
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top