Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Compile-time erros and warnings

Good afternoon.

I'm trying to create a compile time Aspect to do a warning when the System.out.print() and System.out.println() is called from anywhere in my code but that doesn't seem to work and a warning symbol shows up on the left side of the poincut (line 3) (I'm using Eclipse 2.1, Aspect 1.1 and AJDT 0.6.1). Can you tell me what I'm doing wrong? 

The code is the following:

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

- Aspect:

1. public aspect SystemOutListener {
2.				
3.	pointcut systemOut() 
4.		: call( * System.out.*(..)) && within(com.mypackage.*);
5.		
6.	declare error: systemOut()
7.		: "You cannot use System.out.print* directy. Use the Log class instead";
8.			
8. }

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

- Main class:

package com.mypackage;

1. public class Main {
2.	
3.	 public Main () {
4.		
5.		System.out.println("Error");
6.		
7.	 }
8.
9.	 public static void main(String[] args) {
10.		
11.		new Main ();
12.		
13.	 }
14. }

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

Thanks in advance,
Hugo Magalhães 


Back to the top