Classes instrumented but the advice code is not executed.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Classes instrumented but the advice code is not executed.

Omar Javed

Hi,

 

I am using AspectJ version 1.8.9  and I am using the following aspect to instrument classes in dacapo-benchmark (avrora).  

 

import java.util.*;

 

aspect BaseAspect {

pointcut notwithin() :

!within(sun..*) &&

!within(java..*) &&

!within(javax..*) &&

!within(com.sun..*) &&

!within(org.apache.commons..*) &&

!within(org.apache.geronimo..*) &&

!within(net.sf.cglib..*);

}

 

public aspect UnionJoinPointsAspect {

pointcut MOP_CommonPointCut() : !adviceexecution() && BaseAspect.notwithin();                

pointcut SafeSyncMap_syncCreateIter(Set mapSet) : (call(* Collection+.iterator()) && target(mapSet)) && MOP_CommonPointCut();

after (Set mapSet) returning (Iterator iter) : SafeSyncMap_syncCreateIter(mapSet) {

System.out.println(thisEnclosingJoinPointStaticPart.toString());

 

}

}

 When dumping with AspectJ weaver using (<dump> with beforeandafter options in aop-ajc.xml). I could see the class being instrumented e.g. avrora.sim.radio.Medium$BasicArbitrator  and the aspect is woven in method

mergeTransmissions(avrora.sim.radio.Medium$Receiver, java.util.List, long, int) but  advice code (which is the reflective information) cannot be seen in the output, which only shows the following:-

  

===== DaCapo 9.12 avrora starting =====

execution(boolean org.dacapo.harness.Benchmark.validate(String))

===== DaCapo 9.12 avrora PASSED in 1874 msec =====

execution(void org.dacapo.harness.Benchmark.postIterationCleanup(String))

 

Regards,


Omar

 


 


_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Classes instrumented but the advice code is not executed.

Andy Clement
Hi Omar,

So the method mergeTransmissions() has a call into it to the advice?  Normally I verify what is woven using -showWeaveInfo rather than introspecting byte code. Just because it is woven doesn’t mean it will be called because your advice may have caused pre-conditions to be inserted for anything that could not be statically determined when matching your pointcut.

For example there may be places where we cannot tell if the target of the call is a Set at compile time, so for the ‘target’ component of your pointcut a test will be inserted into the code that verifies if the target is a Set, and if it is then we may call the advice (The call(..) component may be inserting other tests).

Break your pointcut down into pieces to help you understand it - for example remove that target (and the associated mapSet handling) - does the advice then get called? If so it is because the collection being operated on is not a Set.

cheers,
Andy


On Apr 18, 2016, at 1:51 AM, Omar Javed <[hidden email]> wrote:

Hi,

 

I am using AspectJ version 1.8.9  and I am using the following aspect to instrument classes in dacapo-benchmark (avrora).  

 

import java.util.*;

 

aspect BaseAspect {
pointcut notwithin() :
!within(sun..*) &&
!within(java..*) &&
!within(javax..*) &&
!within(com.sun..*) &&
!within(org.apache.commons..*) &&
!within(org.apache.geronimo..*) &&
!within(net.sf.cglib..*);
}

 

public aspect UnionJoinPointsAspect {
pointcut MOP_CommonPointCut() : !adviceexecution() && BaseAspect.notwithin();                
pointcut SafeSyncMap_syncCreateIter(Set mapSet) : (call(* Collection+.iterator()) && target(mapSet)) && MOP_CommonPointCut();
after (Set mapSet) returning (Iterator iter) : SafeSyncMap_syncCreateIter(mapSet) {
System.out.println(thisEnclosingJoinPointStaticPart.toString());

 

}
}
 When dumping with AspectJ weaver using (<dump> with beforeandafter options in aop-ajc.xml). I could see the class being instrumented e.g. avrora.sim.radio.Medium$BasicArbitrator  and the aspect is woven in method
mergeTransmissions(avrora.sim.radio.Medium$Receiver, java.util.List, long, int) but  advice code (which is the reflective information) cannot be seen in the output, which only shows the following:-

  

===== DaCapo 9.12 avrora starting =====
execution(boolean org.dacapo.harness.Benchmark.validate(String))
===== DaCapo 9.12 avrora PASSED in 1874 msec =====
execution(void org.dacapo.harness.Benchmark.postIterationCleanup(String))

 

Regards,

Omar

 


 

_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Classes instrumented but the advice code is not executed.

Omar Javed
Hi Andy,

Thanks for the reply.

Yes, mergeTransmissions() has a call into it to the advice.

I removed the target and changed "after returning" to "after" advice type which is as follows:-

                  

                  pointcut SafeSyncMap_syncCreateIter() : call(* Collection+.iterator())  && MOP_CommonPointCut();

                      after () : SafeSyncMap_syncCreateIter() {

                        System.out.println(thisEnclosingJoinPointStaticPart.toString());

                     }


With this aspect, the advice still does not get called. For my understanding, I saw the byte code of couple of classes having the same target of a method call In only one case, the advice is called while for the other cases, advice code is not called, even though they all have the same target. 

Are there any other tests , other than verifying target of a method call? 

Regards,

Omar




From: [hidden email]
Date: Mon, 18 Apr 2016 08:05:39 -0700
To: [hidden email]
Subject: Re: [aspectj-users] Classes instrumented but the advice code is not executed.

Hi Omar,

So the method mergeTransmissions() has a call into it to the advice?  Normally I verify what is woven using -showWeaveInfo rather than introspecting byte code. Just because it is woven doesn’t mean it will be called because your advice may have caused pre-conditions to be inserted for anything that could not be statically determined when matching your pointcut.

For example there may be places where we cannot tell if the target of the call is a Set at compile time, so for the ‘target’ component of your pointcut a test will be inserted into the code that verifies if the target is a Set, and if it is then we may call the advice (The call(..) component may be inserting other tests).

Break your pointcut down into pieces to help you understand it - for example remove that target (and the associated mapSet handling) - does the advice then get called? If so it is because the collection being operated on is not a Set.

cheers,
Andy


On Apr 18, 2016, at 1:51 AM, Omar Javed <[hidden email]> wrote:

Hi,

 

I am using AspectJ version 1.8.9  and I am using the following aspect to instrument classes in dacapo-benchmark (avrora).  

 

import java.util.*;

 

aspect BaseAspect {
pointcut notwithin() :
!within(sun..*) &&
!within(java..*) &&
!within(javax..*) &&
!within(com.sun..*) &&
!within(org.apache.commons..*) &&
!within(org.apache.geronimo..*) &&
!within(net.sf.cglib..*);
}

 

public aspect UnionJoinPointsAspect {
pointcut MOP_CommonPointCut() : !adviceexecution() && BaseAspect.notwithin();                
pointcut SafeSyncMap_syncCreateIter(Set mapSet) : (call(* Collection+.iterator()) && target(mapSet)) && MOP_CommonPointCut();
after (Set mapSet) returning (Iterator iter) : SafeSyncMap_syncCreateIter(mapSet) {
System.out.println(thisEnclosingJoinPointStaticPart.toString());

 

}
}
 When dumping with AspectJ weaver using (<dump> with beforeandafter options in aop-ajc.xml). I could see the class being instrumented e.g. avrora.sim.radio.Medium$BasicArbitrator  and the aspect is woven in method
mergeTransmissions(avrora.sim.radio.Medium$Receiver, java.util.List, long, int) but  advice code (which is the reflective information) cannot be seen in the output, which only shows the following:-

  

===== DaCapo 9.12 avrora starting =====
execution(boolean org.dacapo.harness.Benchmark.validate(String))
===== DaCapo 9.12 avrora PASSED in 1874 msec =====
execution(void org.dacapo.harness.Benchmark.postIterationCleanup(String))

 

Regards,

Omar

 


 

_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________ aspectj-users mailing list [hidden email] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Classes instrumented but the advice code is not executed.

Andy Clement
Have you used -showWeaveInfo to confirm it is weaving what you expect?

All I can suggest is there is something about your join point that isn't quite what you expect. Simplify the call to "call(* iterator())", maybe remove the MOP_CommonPointCut() element (that element also probably doesn't need !adviceexecution() - the normal way to exclude joinpoints in an aspect is to say !within(MyAspectType)). If you reduce it down to simply call(* iterator(..)) and it still isn't working, that would be surprising.

Andy

On 19 April 2016 at 03:54, Omar Javed <[hidden email]> wrote:
Hi Andy,

Thanks for the reply.

Yes, mergeTransmissions() has a call into it to the advice.

I removed the target and changed "after returning" to "after" advice type which is as follows:-

                  

                  pointcut SafeSyncMap_syncCreateIter() : call(* Collection+.iterator())  && MOP_CommonPointCut();

                      after () : SafeSyncMap_syncCreateIter() {

                        System.out.println(thisEnclosingJoinPointStaticPart.toString());

                     }


With this aspect, the advice still does not get called. For my understanding, I saw the byte code of couple of classes having the same target of a method call In only one case, the advice is called while for the other cases, advice code is not called, even though they all have the same target. 

Are there any other tests , other than verifying target of a method call? 

Regards,

Omar




From: [hidden email]
Date: Mon, 18 Apr 2016 08:05:39 -0700
To: [hidden email]
Subject: Re: [aspectj-users] Classes instrumented but the advice code is not executed.


Hi Omar,

So the method mergeTransmissions() has a call into it to the advice?  Normally I verify what is woven using -showWeaveInfo rather than introspecting byte code. Just because it is woven doesn’t mean it will be called because your advice may have caused pre-conditions to be inserted for anything that could not be statically determined when matching your pointcut.

For example there may be places where we cannot tell if the target of the call is a Set at compile time, so for the ‘target’ component of your pointcut a test will be inserted into the code that verifies if the target is a Set, and if it is then we may call the advice (The call(..) component may be inserting other tests).

Break your pointcut down into pieces to help you understand it - for example remove that target (and the associated mapSet handling) - does the advice then get called? If so it is because the collection being operated on is not a Set.

cheers,
Andy


On Apr 18, 2016, at 1:51 AM, Omar Javed <[hidden email]> wrote:

Hi,

 

I am using AspectJ version 1.8.9  and I am using the following aspect to instrument classes in dacapo-benchmark (avrora).  

 

import java.util.*;

 

aspect BaseAspect {
pointcut notwithin() :
!within(sun..*) &&
!within(java..*) &&
!within(javax..*) &&
!within(com.sun..*) &&
!within(org.apache.commons..*) &&
!within(org.apache.geronimo..*) &&
!within(net.sf.cglib..*);
}

 

public aspect UnionJoinPointsAspect {
pointcut MOP_CommonPointCut() : !adviceexecution() && BaseAspect.notwithin();                
pointcut SafeSyncMap_syncCreateIter(Set mapSet) : (call(* Collection+.iterator()) && target(mapSet)) && MOP_CommonPointCut();
after (Set mapSet) returning (Iterator iter) : SafeSyncMap_syncCreateIter(mapSet) {
System.out.println(thisEnclosingJoinPointStaticPart.toString());

 

}
}
 When dumping with AspectJ weaver using (<dump> with beforeandafter options in aop-ajc.xml). I could see the class being instrumented e.g. avrora.sim.radio.Medium$BasicArbitrator  and the aspect is woven in method
mergeTransmissions(avrora.sim.radio.Medium$Receiver, java.util.List, long, int) but  advice code (which is the reflective information) cannot be seen in the output, which only shows the following:-

  

===== DaCapo 9.12 avrora starting =====
execution(boolean org.dacapo.harness.Benchmark.validate(String))
===== DaCapo 9.12 avrora PASSED in 1874 msec =====
execution(void org.dacapo.harness.Benchmark.postIterationCleanup(String))

 

Regards,

Omar

 


 

_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________ aspectj-users mailing list [hidden email] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/aspectj-users

_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users
Loading...