Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] set-pointcut: exposing previous value



Eric,

You have got what you asked for: the args() pointcut extracts the value
passed at the field set joint point not the current value of the field. Do
not be tempted to use "target" either as that is the object that defines
the field not the field itself (see
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg02916.html). You will
have to use reflection of explicit field access to acquire the the value of
the field before update.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/


Eric Bodden <eric@xxxxxxxxx>@eclipse.org on 07/10/2004 07:30:49

Please respond to aspectj-dev@xxxxxxxxxxx

Sent by:    aspectj-dev-admin@xxxxxxxxxxx


To:    aspectj-dev@xxxxxxxxxxx
cc:
Subject:    [aspectj-dev] set-pointcut: exposing previous value



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

I have recently come across a strange behaviour (at least I fin dit
strange) of set-pointcuts. When I have a call, that changes a field
value from let's say 0 to 1, the following code will return 1, not 0
as I had expected:

             before (int a): set(* *.*) && args(a) {
                         System.out.println(a);
             }

So why is that? I thought the semantics of a "before" advice were
that it matches *before* the execution. Apparently it even does,
cause when I employ reflection, the field value has not yet changed
(still 0). However wouldn't it be more consistent to expose the "old"
value to pieces of before/around advice?

Cheers,
Eric

- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQWTimcwiFCm7RlWCEQJJyQCg3VXx8HauulPxFFi792QBcdf+Ct0AnRfY
k0WQShijZ55ZdexG2N8ZWCPB
=ZP8Q
-----END PGP SIGNATURE-----


_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev





Back to the top