Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Load time weaving agent with another java agent

Thanks for the response Alexander. Yes everything other than inserted method calls get woven. 

It seems that AspectJ's transformer gets called before my agent on each class regardless of the order of agents. From ClassFileTransformer's javadoc I see that:

When there are multiple transformers, transformations are composed by chaining the transform calls. That is, the byte array returned by one call to transform becomes the input (via the classfileBuffer parameter) to the next call.

Transformations are applied in the following order:

  • Retransformation incapable transformers
  • Retransformation incapable native transformers
  • Retransformation capable transformers
  • Retransformation capable native transformers

My agent is retransformation capable. I guess aspect weaver's agent is retransformation incapable. 

Anyway the problem got solved by capturing method "execution" rather than "call". This way, I don't need to care about the order of agents. 


Regards,

Ali


On Thu, Mar 26, 2015 at 4:50 AM, Alexander Kriegisch <Alexander@xxxxxxxxxxxxxx> wrote:
Interesting project, Ali.

Does the combination of agents work with other aspects, i.e. ones unrelated to the ASM-inserted method calls? I mean, does anything get woven at all? If so, my guess would be that the byte code ASM produces is not recognised as valid method calls by AspectJ. Otherwise there is another, more basic problem with mixing those agents. I never tried, actually.

Regards
-- 
Alexander Kriegisch


Am 26.03.2015 um 03:58 schrieb Ali Kheradmand <a.i.kheradmand@xxxxxxxxx>:

Hey everybody,

I need to capture array element access in AspectJ. But it seems that AspectJ does not provide such a pointcut. In order to solve this problem my idea was to insert calls to an specific static method before array accesses and capture those method calls in AspectJ.
I wrote a java instrumentation agent (using ASM) that inserts the static method calls before array element accesses. The agent works fine.
I also wrote an aspect that captures that method call. I generated a load time weaving agent using that aspect. And that agent works fine too (by that I mean if I manually add the method calls to source code, the agent captures it at runtime)

Now I try to run both of the agents in order:
java -javaagent:myagent.jar -javaagent:asperctjweaver.jar MyClass

It is said that " Agents are invoked in the same order as specified in options.". and from that I except that myagent would insert method calls before array accesses and asperctjweaver would capture those calls. But it does not work this way: method calls get inserted before array accesses but they do not get captured. However, the method calls that already existed in the source code, get captured. 

Does anybody have any idea on what the problem might be?

Regards,
Ali



_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
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
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top