Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] set() capture oldvalue

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

Tim Schafer wrote:
> That's exactly what I'm doing.
> Using reflection.
> I'm concerned about performance.
> If I were using aspects I wouldn't use refelection in each setter
> to get the old value. 
> The aspect compiler should be able to do this work for me.
> I believe it's a major defeciency that this isn't avaiblable.
> Are there already plans to fix this?
> Should I file a bug?

Hi, Tim.

First of all I am not really sure if people would like to extend the
language that way because it would almost certainly mean introducing
new syntax with a new keywords and so forth and you usually need very
good reasons and (many!) very compelling use cases in order to get
this through.

On the other hand I think there is another solution to this problem:
As they said in 'Back to the future' think in 4 dimensions :-)
When the value gets set, this is captured by the set-pointcut. If
there *is* an old value, this must have been *set* before. So
whenever the set-pointcut matches, do the following in this order:

1.) See if there has previously an "old value" been stored by the
aspect.
2.) If so, execute your piece of code with this old value.
3.) Store the new value. It's going to be the next old value.

This could look like the following:

aspect Foo {


	private Object oldObject = null;

	after(Object newObject): set(* Object Bar.myField) {
		if(oldObject!=null) {
			doSometing(oldObject);
		}
		oldObject = newObject;
	}

}

Hope this makes sense.

Eric

<adv>
P.S. this is a fragement of ongoing work in the communicty about
"temporal pointcuts", which let you pick up exatcly such events. Feel
free to have a look at the tracematch-paper [1] by the abc-team or my
recent publications. Both our approaches provide a language construct
that lets you explicitly access this/target/args value *over time*.

[1] http://abc.comlab.ox.ac.uk/techreports#abc-2005-1
[2] http://bodden.de/publications
</adv>

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

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

iQA/AwUBQoWvlswiFCm7RlWCEQIU0gCfbGmV4qLiR/qjp1doi6AJC/RA/9wAoNkN
lLZxFVLyEMm8RH7QbwluQNkj
=CFi0
-----END PGP SIGNATURE-----




Back to the top