Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] AspectJ Limits

Hi all.

I discovered AspectJ this week and I'm very Impressed. I'm asking myself
how I have been able to develop without it until today ...

althought, there is a point that would be negative for me. Do anybody
knows if it's my mistake ou if it's a well known problem or what ever
else ?

The problem is that AspectJ can only interrupt calls to a class from
calls that are made from my classes. I explain :


public class Test implements Runnable {
	public void run() {
		System.out.println("Hello !");
	}

	public void main(String args[]) {
		new Test().run();
		new Thread(new Test()).start();
	}
}

public aspect TestAspect {

	pointcut whenDoRun() : call(void Test.run(..));
	
	void after() : whenDoRun() {
		System.err.println("BEFORE");
		proceed();
		System.err.println("AFTER");
	}
}


will result of 

BEFORE
Hello !
AFTER
Hello !

i.e. the second call to run() is not wrapped by BEFORE/AFTER because
Thread class has not been modified by AspectJ ...

This can be the same if I use, for example, a bean whose setMethod()
will be called from BeanUtils that use Class.Method.invoke() method ...
There are plenty of other case ..

This mean that, according to the way methods are called, I can't be sure
the call will be intercepted. Then the way the application as been
developped must, I think, know if it will or not use AspectJ. This
contrary the fact that components must only do what they have to do and
no more ...
Also, I can't take an old application and modify it with AspectJ without
touch the old code ...

Thanks in advance.

Mike


Mike Baroukh

Cardiweb  - 31 Rue de Mogador Paris IXeme
06 63 57 27 22 - 01 53 21 82 63 - ICQ: 105910677
http://www.cardiweb.com
--
Les féministes travaillent, picolent, conduisent comme des mecs
et après elles s'étonnent qu'on les encule.
Patrick Timsit
--



Back to the top