Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] problems with constants and inter-type declarations

Hi all,

I'm having problems while trying to insert constants in a class via inter-type declarations. Consider the following class and aspect:

public class Foo {
    public void bar(){
        int i = 2;
        switch(i){
        case L1:
            System.out.println("L1 selected.");
            break;
       
        case L2:
            System.out.println("L2 selected.");
            break;
        }
    }
}

public aspect FooAspect {
    public static final int Foo.L1 = 1;
    public static final int Foo.L2 = 2;
}


As you can see, the aspect inserts 2 constants in the Foo class, which are used as case expressions in the switch statement. However, the compiler says that "case expressions must be constant expressions". Now, is this a bug or am I doing something wrong?

I'm using Eclipse 3.1 and AJDT 1.3.1

any advice is greatly appreciated.

Davi Pires

Back to the top