[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Creating a crosscut using ClassLoader.Loadclass using AspectJ

Since you aren't (likely) weaving the code that calls ClassLoader.loadClass(), you pointcut won't work.

You should perhaps try something like:

pointcut classLoading() : staticinitialization(*);

Then in advice, you can get access to the class object using thisJoinPoint.getSignature().getDeclaringType().


On Dec 30, 2007 10:25 PM, Boudewijn Ector < boudewijn@xxxxxxxxxxxxxxxxx> wrote:
Dear peole,

For a university assignment, I had to do a number of assignments. One of
these (the last one) is creating an aspect which checks for code
coverage, specifically function coverage.

To do so, I planned to use a crosscut on the ClassLoader.LoadClass
function, so I can check each class which is loaded in order to list
it's methods (it's okay to check only the loaded classes).

But whatever I'm doing, the Aspect just won't get triggered.
My current code :

after() returning(Class <?> c):  target(ClassLoader) &&  call (Class<?>
loadClass(..))  && !within(SWE35)

SWE35 is the current aspect. Afaik, this should work but I've also
tested while removing the <?> part (generics don't have to be
explicitely mentioned afaik). Can someone tell me what I'm doing wrong?
I've written succesfully about 25 aspects, but I just can't figure this
one out.

I'm using Sun Java 1.6 on a Linux box, and Eclipse-3.2 using it's
respective AspectJ plugin (the newest one) without further security


Boudewijn Ector
aspectj-users mailing list