[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-dev] exceptions and around
|
Eric,
Remember that if you soften the exception, it will be rethrown as a SoftException. So depending on the join point at which you soften, you may need to catch a SoftException. This code works for me:
import java.io.IOException;
aspect TestSoften {
pointcut scope() : call(void testThrowIO());
declare soft: IOException: scope();
void around(): scope() {
try {
proceed();
}catch(org.aspectj.lang.SoftException x) {
System.out.println("file does not exist.");
}
}
public static void main(String args[]) { testThrowIO(); }
static void testThrowIO() throws IOException {
throw new IOException();
}
}
Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895
> ------------Original Message------------
> From: "Eric Macaulay" <eeoam@xxxxxxxxx>
> To: <aspectj-dev@xxxxxxxxxxx>
> Date: Thu, Jun-3-2004 2:40 AM
> Subject: Re: [aspectj-dev] exceptions and around
>
> I've softened the exception, but when I run the program the code in the
> catch clause is not executed.
>
> Eric Macaulay
>
> ----- Original Message -----
> From: Ramnivas Laddad <ramnivas@xxxxxxxxx>
> To: <aspectj-dev@xxxxxxxxxxx>
> Sent: Wednesday, June 02, 2004 11:18 PM
> Subject: Re: [aspectj-dev] exceptions and around
>
>
> > You will need to soften the IOException by adding:
> >
> > declare soft: IOException: call(void Properties.load(InputStream));
> >
> > -Ramnivas
> >
> > --- Eric Macaulay <eeoam@xxxxxxxxx> wrote:
> > > I have the following constructor:
> > >
> > > public Server() {
> > > Properties props = new Properties();
> > > props.load(new FileInputStream("properties"));
> > >
> > > new Thread(new HTTPServer(1980)).start();
> > > System.out.println("server running...");
> > > }
> > >
> > > and the following advice:
> > >
> > > void around(): within(Server) && (call(void
> > > Properties.load(InputStream))){
> > > try {
> > > System.out.println("opening properties file ...");
> > > proceed();
> > > }catch(IOException x) {
> > > System.out.println("file does not exist.");
> > > }
> > > }
> > >
> > > However I'm still getting a compiler error complaining that the
> > > IOException has not been handled. Any thoughts?
> > >
> > >
> > > Eric Macaulay
> > >
> > >
> >
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Friends. Fun. Try the all-new Yahoo! Messenger.
> > http://messenger.yahoo.com/
> > _______________________________________________
> > aspectj-dev mailing list
> > aspectj-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> >
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>