[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] cflowbelow does not work in constructor?

I have an aspect A and a java class C like the following. I want to do something (in my example, it is printing out a message) ONCE after an instnace of C is constructed. Because I just want this thing be done ONCE, I use !cflowbelow to prevent things done when a constuctor invocation is called by top level constructor. However, it does not work. The printing message is printed twice.  Does cflowbelow not work in constructor? Or what I do is wrong?

aspect A {
    // TODO why does cflowbelow not behavior correctly on constructor like on method?
    pointcut construction(C c):
        execution(C.new(..)) &&
    after(C c) returning:
            construction(c) &&
            !cflowbelow(construction(C)) {
        System.out.println("a C instance constructed");

class C {
  private int n;

  public C() {

  public C(int n) {
     this.n = n;

    public static void main(String[] args) {
        C c = new C();