I am a bit confused.  Do you want to catch constructor calls made from the
BarInterface or construction of things implementing BarInterface - I'll
assume the latter.  This:

public pointcut PT_new() :
      within(com.foo.BarInterface) &&
      call(*.new(..));

means calls to any constructor made from within BarInterface - there isn't
usually much code in an interface so you won't match much with that.  Adding
a + to BarInterface will mean calls to any constructor (of anything)  made
from within BarInterface or a subtype of it. (In neither case has a
restriction been placed on the type of the object being constructed)

If you want to catch construction of classes implementing BarInterface, you
need to specify the type pattern in the call pointcut:

interface SomeInterface { }

class C implements SomeInterface { }
class D implements SomeInterface { }

aspect X {
        public static void main(String []argv) {
                new C(); // advised
                new D(); // advised
        }

        before(): call(SomeInterface+.new(..)) {}
}

Note: because execution() join points occur in the same type as you are
naming using within() - you will have been getting away with using within()
and execution() together:

execution(*.new(..)) && within(SomeInterface+);

that just wont work for call() and within()

Andy.
2008/12/3 Andrew Eisenberg <[EMAIL PROTECTED]>

> >   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
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to