[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] final variables
|
Hello Paulo,
My problem is not preventing the name (I have also used that method before
for packages!) but capturing variables defined as final. I suppose that, with
the snippet of code you have sent, you are only capturing static variables
that, actually, are also final. Try to run the example I have put here (using
the final modifier in the declaration pointcut, but not the static one) and
my question will make much more sense, I suppose.
Thanks for your answer, anyway :)
Regards,
Paulo Zenida
Em Sexta, 13 de Janeiro de 2006 16:46, o Paulo Merson escreveu:
> Here's how you can check that the final *member variables* do not
> contain lower case letters. There's a caveat: it doesn't work for String
> or primitive type constants, because Java requires them to be inlined. I
> also suggest specifying your package scope (e.g., "static final *
> com.acme..*+.*a*") to avoid matching things like System.out.
>
> declare warning :
> get(static final * *a*) ||
> set(static final * *a*) ||
> get(static final * *b*) ||
> set(static final * *b*) ||
> ...
> get(static final * *z*) ||
> set(static final * *z*) :
> "Names of constants should not contain lower case letters.";
>
>
> Paulo Merson
>
> Paulo Alexandre Corigo Zenida wrote:
> >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
> >_______________________________________________
> >aspectj-users mailing list
> >aspectj-users@xxxxxxxxxxx
> >https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users