Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] final variables

Good afternoon,

	I am trying to enforce the naming convention in which one says that final 
"the names of variables declared class constants and of ANSI constants should 
be all uppercase with words separated by underscores ("_"). (ANSI constants 
should be avoided, for ease of debugging.)" (in 
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#367).

	The source code I tried to enforce this is the following:

public class A {

	private final String RIGHT_NAME = "1";
			
	private final String wrong_name;
	
	private int x = 1;
	
	{
		final String x = "1";
		System.out.println(x);
	}
	
	public A() {
		wrong_name = "2";
		System.out.println(RIGHT_NAME + "," + wrong_name);
		System.out.println(x);
	}
}

public aspect EnforceFinalVariablesNamingConventionAspect {

	public pointcut x() :
		set(final * *.*) ||
		get(final * *.*);

	// it's capturing only gets, and all gets, final or not. Why?!
	declare warning : 
		x() : 
			"Final variable";
}


	Am I doing something wrong or what I'm trying to do is not possible?

	Thanks in advance. Best regards,

		Paulo Zenida


Back to the top