Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] cflow or something like that

Jeffrey D Palm wrote:
robert kuzelj wrote:

hi,

how do i solve the following situation

i have two class
class A{public void executeA(){...}}
class B{public void executeB(){...}}

what i want to do is to get the execution
of B.executeB but only if its called
by A. the problem thou is that executeB
is never directly called by A thou its
somewhere in the callstack.
>
> Does this work for you?

nope!

but there is one important piece of information
i forgot in my previous mail.

class A is not available in source code to me.
its a jar file i cannot weave into.

ciao robertj



public class Bob {

  static class A{void executeA(){ System.out.println("A"); c(); }}
  static class B{void executeB(){ System.out.println("B");      }}
  static void c() { new B().executeB(); }

  static aspect Aspect {
    pointcut p(): execution(* B.executeB())
               && cflow(execution(* A.executeA()));
    before(): p() { System.out.println(thisJoinPoint); }
  }

  public static void main(String[] args) {
    new A().executeA();
    new B().executeB();
    c();
  }
}



Back to the top