Community
Participate
Working Groups
I recently had a conversation with Ron Bodkin after I gave a presentation on AOP and AspectJ to the local JUG. One of the questions was: "How can you tell if a jar has had an aspect woven into it?" This is a very good question. I propose a new tool: ajp - disassemble/process/whatever the aspect'd jar and/or .class files and report on what aspects have been installed. Useful info: what JP's captured; what class extensions (a.k.a. Inter-type decls); what 'hard' exceptions 'softened' ...
A patch implementing this tool would be great, but the core team is unlikely to get to it real soon.
Mini spec for Andrew to start on this: 1. Command line tool initially 2. run with ajp.bat/ajp.sh 3. Options are similar to those on javap (pick those appropriate) 4. In addition to taking a specific class, can be passed a jar (maybe a directory??) and processes everything in that jar (and maybe directory) 5. first interesting data is: - Was the class woven at all? - What version of the weaver was used to weave it (not sure if this is available). - For aspects, what level of AspectJ was used to build the aspect (captured in WeaverVersion attribute, see the static fields in the attribute class that tell you what attribute values mean what version) Get that working then there are loads of things we then could do (list pointcuts, list advice - so that they come out *as* advice rather than mangled methods which is what you see if you javap it). No doubt some of the features will require aspectj changes to enhance what is stored in a woven class. To see how to get hold of the object you want to query for attributes etc, see examples like BcelTestCase and MethodAnnotationsTest in the bcel-builder project.
Probably exists as a new top level module - its a new tool, like ajdoc. And perhaps don't use BCEL directly, just depend on the weaver module and use the 'World' in weaver, asking it to load types from a specific location (jar/dir/path) and then querying them that way - that will give us flexibility if we switch bytecode toolkit. So... doing it this way, take a look at WorldTestCase which resolves types in a world.
javap takes a classpath and a list of classes e.g. "javap -classpath foo.jar com.ibm.foo.Foo com.ibm.foo.Goo". Perhaps we could follow this but allow simple wildcards for class names. We could also use a verbose flag in the future to specify whether to include more detailed info like pointcuts, ITDs etc
I've made a little prototype.. given the compiled+woven version of this: class Meep { public void a(){} public int anInt; } aspect AdviseMeep { pointcut p():execution(public void Meep.a()); before():p(){ } public void b(){} } it produces this output: Compiled from "Meep.aj" Woven reweavable with ajc 1.5.0 Touched by AdviseMeep class Meep extends java.lang.Object { public int anInt; Meep(); public void a(); } Compiled from "Meep.aj" Woven reweavable with ajc 1.5.0 Not touched by any aspects aspect AdviseMeep extends java.lang.Object issingleton() { static {}; AdviseMeep(); public void b(); pointcut p() : execution(public void Meep.a()); before : p(); } or when Meep etc was compiled with AspectJ 1.2.1 non-reweavable it says: Compiled from "Meep.aj" Woven non-reweavable with ajc 1.2.1 class Meep extends java.lang.Object { public int anInt; Meep(); public void a(); } Compiled from "Meep.aj" Woven non-reweavable with ajc 1.2.1 aspect AdviseMeep extends java.lang.Object issingleton() { static {}; AdviseMeep(); public void b(); pointcut p() : execution(public void Meep.a()); before : p(); }
Created attachment 26409 [details] contains patches and the new ajp project This jar contains the current ajp project, and the patches it requires in the other projects.
for M4
not going to make it in 1.5.0. May need changing too if we switch from attributes to annotations in 1.5.1.
We really need this. Especially to help with LTW problem diagnosis. Can we simplify what it produces so that it makes 1.5.0?
What do you need (minimum) to debug LTW?
1. Whether a class file contains a class or an aspect 2. Which version of AspectJ was used 3. Which aspects were woven into this class
not gonna make it for 1.5.1
It has been more than a couple of years since I opened this bug - if no one objects, I'll set it to 'WONTFIX'
Well Andrew did contribute the tool (comment 6) but I would say that priority 5s don't get looked at very often. If you wish to close it - that is ok, but I don't need it closed.
I'll close it - can always re-open