[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Counting # of Methods/Classes
|
Marko is right that this isn't normally an AspectJ usage, but I guess
you could achieve it with this aspect:
aspect X {
before(): execution(* *(..)) {}
}
ajc X.aj -inpath somecode.jar -showWeaveInfo | grep "advised by" | wc -l
So I'm producing weaving messages as I weave some code then counting
the number of messages.
cheers,
Andy
On 17 November 2012 05:36, Marko Umek <marko.umek@xxxxxxxxxxxxx> wrote:
> Hi Hmil,
>
> This is not a question of AspectJ. You should read the classes directly from
> the JAR-Files (CLASSPATH), load each class and then do some reflection:
>
> for( String filename : <content of class.path> )
> {
> Class
> theClass=Class.forName(filename.replace(".class","").replace("/","."));
> Method[] methods=theClass.getDeclaredMethods();
>
> countClasses++;
> countMethods+=methods.length;
> }
>
> You can do this with AspectJ, but you still have to load each class: Aspects
> do not apply on none loaded classes.
>
> Regards Marko
>
>
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/Counting-of-Methods-Classes-tp4650617p4650618.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users