Hi,

I am stuck with exception handling in aspectj.

Let's say in a method in the class I execute the following snippet:

void methodSocket() {

try {
  
 socket.connect(new InetSocketAddress(" www.google.de",80),200);
}catch(IOException e)  {
  e.printStackTrace();
}
}

I would like to remove the exception handling from methodSocket and encapsulate it within an aspect as follows:

void methodSocket() {
 socket.connect(new InetSocketAddress("www.google.de",80),20);
}

public aspect SocketAspect {

   pointcut p(): call(* java.net.Socket.connect (..));

 after(): p() {
     throw new IOException();
 }
}

What is wrong with this aspect? How can I achieve my aim?

Thanks in advance
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to