Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] WeavingAdapter - how to use it?

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...

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.

> 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?

> 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.

Andy


Back to the top