Community
Participate
Working Groups
Hi, for the dynamic weaving functionality I implemented for the Eclipse runtime I need to know which aspect got woven into which class. Therefore it would be good if the weaver would generate messages during the bytecode weaving. Those specialized messages could contain information for the aspect and the class. I implemented a special subclass of Message and added the creation of the message to the BcelAdvice class (a simple test case for this as well). Take a look at the patch for details. I used the Message.INFO kind for this to not modify the IMessage interface. It might be better to have a special IMessage.Kind for that, something like "WOVEN". I think there are more places (in addition to BcelAdvice.implementOn(..)) where this kind of information should be generated, but I am not familiar enough to implement them all.
Created attachment 4661 [details] simple WovenMessage implementation
Created attachment 4820 [details] messages for type mungers I added the message generation to the BcelTypeMunger class to get messages if only types are changed by the weaving process.
This is related to bug 44415
I'm appending to the bug rather than sticking this on the aspectj-dev list to limit the exposure until its had a bit of testing. It is quite a messy patch so I have built a distribution of aspectj with support in for weaving messages. I hope thats ok for you... You can get it here: http://download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT- WEAVEINFO.jar (The level of AspectJ is actually 1.2rc2 inside there) I'd appreciate any feedback on it, log any problems with it in this bug report rather than raising real bugs yet. I've tested it for source/binary weaves and for cases when binary weaves are missing debug information. But, no doubt I've missed something! And this afternoon I had a go at extending the messages to indicate whether there is dynamic residue for an advice match (i.e. has a runtime test been added to the code). For the tjp demo in aspectj examples I get: C:\aspectj1.2\doc\examples\tjp>ajc -showWeaveInfo *.java Type 'tjp.Demo' (Demo.java:20) advised by around advice from 'tjp.GetInfo' (GetInfo.java:26) [RuntimeTest=true] Type 'tjp.Demo' (Demo.java:30) advised by around advice from 'tjp.GetInfo' (GetInfo.java:26) [RuntimeTest=true] Type 'tjp.Demo' (Demo.java:34) advised by around advice from 'tjp.GetInfo' (GetInfo.java:26) [RuntimeTest=true] (The related pointcuts include cflow, hence runtime test is 'true') -showWeaveInfo is the command line option to switch it on. showweaveinfo="true" is the IAJC ANT task option to switch it on. You will get messages for: before/after/around/afterreturning/afterthrowing/declareparents/declaresoft and ITDs. One situation where it may misbehave at the moment is if you use your own message handlers...
The binary distribution is a bit complicated for me since I have to include the source of the weaver into my project to use it. Nevertheless the output seems to provide all necessary information. Would be nice to have a simple api to extract the information (class name and aspect name) from the messages.
Available in build (phew): BUILD COMPLETE - build.327 Date of build: 08/05/2004 17:51:19 Time to build: 93 minutes 33 seconds Last changed: 08/05/2004 17:20:15 Latest good AspectJ jar available at: download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar I'll resolve this as fixed for now (just to get the bug numbers down!). If you try it and decide you definetly need to extract info from the messages, I'll accept an enhancement request for that ... :)
I took a closer look at your implementation and there is only one tiny little thing that is missing (to make it suitable for my needs). The class WeaveMessage should provide a method to get the full-qualified name of the aspect it refers to. Thats all. ;-)
Fix released as part of AspectJ 1.2.1