Bug 48698 - RFE: A tool to determine what aspects have been woven into a given jar
Summary: RFE: A tool to determine what aspects have been woven into a given jar
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-13 10:12 EST by Mike Norman CLA
Modified: 2012-04-03 16:06 EDT (History)
3 users (show)

See Also:


Attachments
contains patches and the new ajp project (678.61 KB, patch)
2005-08-24 11:49 EDT, Andrew J Huff CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Norman CLA 2003-12-13 10:12:09 EST
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' ...
Comment 1 Jim Hugunin CLA 2004-01-14 11:43:31 EST
A patch implementing this tool would be great, but the core team is unlikely
to get to it real soon.
Comment 2 Andrew Clement CLA 2005-07-08 06:16:10 EDT
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.
Comment 3 Andrew Clement CLA 2005-07-08 06:19:39 EDT
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.
Comment 4 Matthew Webster CLA 2005-07-08 07:39:24 EDT
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
Comment 5 Andrew J Huff CLA 2005-07-12 09:58:22 EDT
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();
}
Comment 6 Andrew J Huff CLA 2005-08-24 11:49:13 EDT
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.
Comment 7 Adrian Colyer CLA 2005-08-26 11:54:52 EDT
for M4
Comment 8 Andrew Clement CLA 2005-10-27 06:36:33 EDT
not going to make it in 1.5.0.  May need changing too if we switch from
attributes to annotations in 1.5.1.
Comment 9 Matthew Webster CLA 2005-10-27 07:53:54 EDT
We really need this. Especially to help with LTW problem diagnosis. Can we 
simplify what it produces so that it makes 1.5.0?
Comment 10 Andrew Clement CLA 2005-10-27 08:59:05 EDT
What do you need (minimum) to debug LTW?  
Comment 11 Matthew Webster CLA 2005-10-27 12:24:16 EDT
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
Comment 12 Andrew Clement CLA 2006-03-27 03:46:09 EST
not gonna make it for 1.5.1
Comment 13 Mike Norman CLA 2009-05-27 09:30:18 EDT
It has been more than a couple of years since I opened this bug - 
if no one objects, I'll set it to 'WONTFIX'
Comment 14 Andrew Clement CLA 2009-05-27 11:57:29 EDT
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.
Comment 15 Mike Norman CLA 2009-05-27 12:53:56 EDT
I'll close it - can always re-open