[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] WeavingAdapter - how to use it?
|
Hello,
thank you for the replies!
On Nov 20, 2009, at 11:45 PM, Andy Clement wrote:
> Hi,
>
>> I use my own agent, to perform other types of analysis on the bytecode. Thus I would like to use the load-time facilities offered
>> by AspectJ out of their normal context. I searched a bit and I found WeaverAdapter. However, what is not clear to me is how
>> to use it. Could someone point me to a tutorial, example, etc?
>
> Unfortunately there is no real documentation on that. You may find
> some googling through the mailing list archives as a few people have
> done it before, but it hasn't been formally written up due to lack of
> time. If anyone wants to help out fleshing out the details, the wiki
> space on http://wiki.eclipse.org/AspectJ would be a great place to
> document it...
I found such a question, with example code, but I wasn't able to instrument anything :(.
Please find attached the source code for my little experiment. I followed some guidelines I found in a previous mail sent to this list. However, it does not work for me.
I should mention I am using Java 6, with AspectJ 1.6.6
Attachment:
Example.zip
Description: Example.zip
To run a small test, compile the code and execute
java TestStatic Test.class
This will output the INSTR_Test.class file that one can rename to Test.class and inspect with
javap -c -private Test
This will show that the instrumentation has not been performed.
>
> My initial advice would be to look at how it is used by AspectJ
> itself. See the Aj/WeavingURLClassLoader class and other types in
> that package.
>
>> I would like to ask what is the GeneratedClassHandler for?
>
> As part of weaving, AspectJ may create classes, for example marker
> interfaces or closures for around advice weaving. These are passed to
> the GeneratedClassHandler which should decide what to do with them -
> probably define them to the classloader.
>
Thanks for clearing that up!
>> Also, do I need to pass to the WeaverAdapter the entire classpath for the classes, since I already have the bytes of the class I want to instrument?
>
> The weaver (inside the adapter) will need to be able to resolve types.
> It won't weave anything you don't ask it to, but in the process of
> weaving what you want it may need to look up many types to determine
> whether pointcuts match. Is there a reason you can't just give it a
> suitable classpath?
>
You're right.
>> Also, for the URLs for the aspects, do these have to point to an .aj file? or a compiled version? I tried with the ".aj" files but no success.
>
> Compiled version, there is no on the fly compilation. Although LTW
> does support a rudimentary form of defining aspects in aop.xml.
I used ajc with the option of creating a jar.
Best regards,
Silviu
>
> Andy
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users