I have captured my problem in the following sample code. HelloWorld class is
my source which needs to be instrumented by HelloWorldTracer aspect. My
objective is to find all the method calls which are in the control flow of
HelloWorld.main(). But I'm not interested in the method calls related to any
types in the package java.lang.* (eg: java.lang.StringBuilder).

package com.abc;

public class HelloWorld {

    public static void main(String args[]) {
        StringBuilder str = new StringBuilder();
        str.toString();
        Sample.testMethod();
    }
}

package com.abc;

public class Sample {

    public static void testMethod()
    {
        StringBuilder str = new StringBuilder();
        str.toString();
    }

}


public aspect HelloWorldTracer {

    pointcut helloWorldTracker() :
        execution(* com.sybase.HelloWorld.main(..)) && within(com.abc..*)
&&  !within(HelloWorldTracer);

    pointcut methodTracker():
         cflow(helloWorldTracker())
         && !within(java.lang..*) && !within(HelloWorldTracer);

    Object around(): methodTracker()
    {

        System.out.println("Inside advice..." +
thisJoinPointStaticPart.getSignature().toString() );
        Object o = proceed();
        return o;
    }

}

Using the poincuts mentioned above the type StringBuilder is also getting
adviced even though !within(java.lang..*) has been explicitly specified in
methodTracker() pointcut. I also tried !within(java.lang.StringBuilder) and
!executoin(String java.langStringBuilder.toString(..)) as well, but in vain.
Any help in restricting the types from java.lang..* from getting adviced
will be appreciated.
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to