Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] staticinitializer

Jake Whitehill wrote:
> Thanks for your response. I actually knew how to obtain the r-value, but
> it's the l-value that I'm unsure about: what expression can I enter to
> refer to each of A, B, and C (from my example) at the same time? Keep in
> mind, my goal is to write one line of code that causes A.x = "A", that
> causes B.x = "B", and that causes C.x = "C".
> 
> Any ideas?

I'd use reflection.  Something like (ignoring error handling):

after() returning: staticinitialization(A || B || C) {
    Class c = thisJoinPoint.getSignature().getDeclaringType();
    c.getField("x").set(null, c.getName());
}

-Jim


Back to the top