Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Intercepting field access and thread-safety

Hi,

Sorry for the late reply, we are all at Spring One 2GX.  How about:

public class Code {
  int i = 5;
  public static void main(String[] argv) {
    new Code().foo();
  }
  public void foo() {
    System.out.println(i);
  }
}

aspect X {
  int around(): get(int Code.i) {
    return 42;
  }
}

Does that do what you want?

Andy

On 16 October 2012 12:16, Sertic Mirko, Bedag <Mirko.Sertic@xxxxxxxx> wrote:
> Hi there
>
> I'd like to know if it's possible to incercept a get field access using
> AspectJ and modify the returned value.
>
> Of course i could modify the field and set a new value using a before
> advice, but if the affected instance would be used in a multi threaded
> environment, this could lead to unwanted race conditions. So it is possible
> to intercept a field get access and return a defined value without modifying
> the original value of the field?
>
> Thanks a lot
>
> Mirko
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top