Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] An intertype declaration question

Hi, I have the following class:
class Test
{
  ... main(String []) {
   Test t = new Test(1); // a constructor defined in aspect
   System.out.println(t.mem); // a public member declared in aspect
}
and the following aspect
1 aspect ATest{
2   private int mem = 0;
3   public int Test.mem = 0;
4   public Test.new(int nop) {
5    mem = 8;
6 }

The value of mem is 8, although "mem" at line 6 should refer to the aspect
instance but not the class instance, which should not influence the
output. Have I made a mistake here or  misunderstood the semantics? How do
I access aspect instance variable in this case?

Thanks.

Charles



Back to the top