[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Perobject association (was: [aspectj-dev] pertypewithin() vs. pertype() association...)

I've been thinking about perobject aspects in the shower and I've decided that the current perobject aspects handle several concerns. I think it's worth dissecting them for greater clarity of thinking:

1) The set of types with which the aspect could possibly be associated
* This set of types is "prepared" in the current implementation to receive aspect association by adding an "invisible" ITD pointing to the aspect

2) The set of join points at which the aspect can become associated with an instance of one of the legal types
* Note, this does not have to be implicit, there's room for programmatic association via some sort of associate() call per Eric's example:

    after() returning(Object o): call(* Factory.instanceOf()) {

3) The set of join points at which the aspect can become disassociated with a previously associated instance
* The current implementation does not address this, though I wish that it did, see earlier email

4) The qualification of all advice declared in the aspect with an additional runtime test of the form

Ideally, the perobject aspects would give the programmer control over all four concerns. Ok, that's all I have for now. Does anyone want to pick up this ball and run it the next few yards?

Nicholas Lesiecki, software craftsman
m: 520 591-1849
Every time we sit down to eat, we make a choice. Consider a compassionate meal.

On Jan 25, 2005, at 3:52 PM, Eric Bodden wrote:

Hi all.

P.P.S. - Eric, re:
I have actually found
quite some use cases where you want to associate aspect instances with
a certain object which is *not* necessarily exposed through a given
It would be useful to post about these cases, at least to
see if there are any workarounds.

Ok, I think I mentioned this already a few months ago in a somewhat
different context. One use case for example is for instance if I want to
reason about certain objects being created by a factory method, say
"getInstance()". So for example I want to say "For each instance created by
Factory.getInstance(), associate an aspect with this instance which tracks
its lifecycle.". In our particular, we would be using this for a runtime
verification approach.

For example, what I would like to be able to express is:

At the moment, I *think* the only way is...

a) to use inter type declerations to store object-dependent state within the
object instead the aspect. This however only works for reference types (I
cannot use inter type declerations let's say on an "int", can I?), or...

b) use HashTables or similar to associate such state with a certain object.

Please correct me if I am wrong.

An *informal* approach of what I am trying to formulate would be something
like the following:

aspect Tracking perreturn(call(* Object Factory.instanceOf()) {

    //some pieces of advice checking certain conditions
    //during the lifecycle of the associated object


with "association aspects" this could easily be implemented using an
explicit instantiation with "associate":

aspect Tracking perobject(Object) {

    after() returning(Object o): call(* Factory.instanceOf()) {


This would also make the pertype-thingy only a special case since one could
easily formulate a pertypewithin(<TypeExpression>) as something like:

aspect aspect perobject(Object) {

    after(): staticinitialization(Object o) {


I really think that this is a powerful and elegant extension to AspectJ. The
aforementioned paper as well as this one explain further applications quite
a bit: "Implementation of Contracts using Association Aspects Notated code"

Would be great if you could support this powerful feature at least in the
long term!

Thank you a lot,


aspectj-dev mailing list