Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Compile-time errors

Good afternoon.

It's possible to create an compile time Aspect to see if each listener added to a model is also removed from the model when appropried? The reason for this is that our application has memory leaks due to the fact that not all of our listeners are removed when appropried, and because it's an application with a considerable amount of code, this type of Aspect could be a great help in finding those lost listeners.

I´ve created an Aspect with two pointcuts that catch all methods that add listeners to a model and all that remove listeners but they work independently. Is there any way to put them to work together?

The code is the following:

----------------------------------------------

- Aspect:

1.  public aspect EventCallListener {
2.				
3.  pointcut addListenerCall(Object model, java.util.EventListener listener)
4.	 : call(void *.add*Listener(java.util.EventListener+))
5.	 && target(model) && args(listener);
6.		
7.  pointcut removeListenerCall(Object model, java.util.EventListener listener)
8.	 : call(void *.remove*Listener(java.util.EventListener+))
9.	 && target(model) && args(listener);
10.		
11. declare error: addListenerCall(Object, java.util.EventListener)
12.	 : "Listener added";
13.		
14. declare error: removeListenerCall(Object, java.util.EventListener)
15.	 : "Listener removed";
16			
17. }

-----------------------------------------------

Thanks in advance,
Hugo Magalhães 





Back to the top