Following on from yesterdays post, I've now uploaded
a dev build of AspectJ where @annotation can be used for
binding with *any* of the kinded PCDs. (yesterday it was
just call/execution)
static aspect X { before(Colored c): set(* *) &&
@annotation(c) { if (c.value().equals("red"))
System.err.println("The
red field is being set!!"); } }
} ---------8<-----------------
You can even write this:
before(Colored c): @annotation(c) { }
which will bind to Colored annotations at any of the
join points encountered. Here is a useful table from the
developers notebook - it tells you what the subject for each
join point kind. It is the subject which we attempt annotation matching
on for that join point:
Join Point Kind Subject Method call The
method picked out by Java as the static target of the method call. Method execution The method that
is executing. Constructor call The constructor
being called. Constructor execution The constructor executing. Field get
The field being accessed. Field set
The field being set. Pre-initialization The first constructor
executing in this constructor chain. Initialization The first
constructor executing in this constructor chain. Static initialization The type being initialized. Handler
The declared type of the exception being handled.Advice executionThe
advice being executed.
Two pieces of annotation binding work remain, @this()
and @args().
Any feedback is welcomed - an AJDT containing this
feature will be available shortly.
cheers, Andy --- Andy Clement. AspectJ Development clemas@xxxxxxxxxx