Skip to main content

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

Thanks for the answer. How do I access the aspect instance variable "mem"
from the declared constructor in this case?

Charles

On Fri, 30 Jan 2004, Nicholas Lesiecki wrote:

> I believe a careful review of the programming guide will answer this
> question. But the short answer is mem at line 5 refers to Test's mem, not
> Atest's mem.
>
> Cheers,
> nick
>
> On 1/29/04 3:16 PM, "Charles Zhang" <czhang@xxxxxxxxxxxxxxxx> wrote:
>
> > 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
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-users
>
> --
> Nicholas Lesiecki
> Software Craftsman, specializing in J2EE,
> Agile Methods, and aspect-oriented programming
>
> Check out my books:
> * Mastering AspectJ: http://tinyurl.com/66vf
> * Java Tools for Extreme Programming: http://tinyurl.com/66vt
>
> Check out my articles on AspectJ:
> * http://tinyurl.com/66vu and http://tinyurl.com/66vv
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top