Cool thanks, but NOTE that DIDN'T work for me either. I did find
something that did thanks to the "+" you pointed out.
NO
public pointcut PT_new() :
within(com.foo.BarInterface+) && // not sure why this doesn't work??
call(*.new(..));
YES
public pointcut PT_new() :
call(public com.foo.BarInterface+.new(..));
TWO MORE QUESTIONS.
QUESTION 1
Can someone explain the difference in behavior here between call and
execute?? I'm not sure i'm really caught on to the difference in these
two.
public pointcut PT_new() :
call(public com.foo.BarInterface+.new(..));
Object around()
throws Exception :
PT_new() {
return null;
}
BarInterface bar = new BarInterfaceImpl();
Here bar == null
public pointcut PT_new() :
execute(public com.foo.BarInterface+.new(..));
Object around()
throws Exception :
PT_new() {
return null;
}
BarInterface bar = new BarInterfaceImpl();
Here bar != null, rather its a new BarInterfaceImpl instance
QUESTION 2
What happens when a the original method does not throw an Exception but
the advice throws an Exception?? Does the "throws Exception" get woven
into the original Constructor (or Method)? I tested it and i guess you
would just get an unhandled exception. This seems real bad and i guess
is something to watch out for??
e.g.
public class BarInterfaceImpl implements BarInterface {
public BarInterfaceImpl() {} // does not throw Exception
}
public pointcut PT_new() :
call(public com.foo.BarInterface+.new(..));
Object around()
throws Exception :
PT_new() {
throw Exception();
}
Andrew Eisenberg wrote:
public pointcut PT_new() :
within(com.foo.BarInterface) &&
call(*.new(..));
Try this instead:
public pointcut PT_new() :
within(com.foo.BarInterface+) &&
call(*.new(..));
'+' means to include subclasses.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users