Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Once again aboutn non-this access

> it will be very useful to be able to
> distinguish access to self instance fields and access to fields of
> other objects (non-this access).
..
> only one way how to express
> correspondent pointcut in AspectJ: comparing result of this() and
> target(). But it is translated by AspectJ in runtime check! So it is
> in any case impossible to avoid AOP overhead for accessing self
> instance fields.

You can use within(), but it doesn't really help.

A join point has a signature specifying only types, so
it seems like a dynamic test is needed.

Assuming the join point signature were changed to include
an attribute for the invoking reference indicating
whether it was directly (but explicitly or implicitly)
via "this", consider

   class Foo {
       int i;
       Bar o;
       int incBoth(Foo foo) {
          return (i++ + foo.i++); // foo:foo==this?
       }
       int incMe() {
          return incBoth(this);
       }
       int incMeAgain() {
          Foo me  = this;        // not a join point
          return incBoth(me);
       }
       public String toString() {
          Bar p = (o == null ? Bar.CONST : o);
          return p.toString();
       }
   }

If it were supported, it would seem arbitary and
would hide the real semantics, which are dynamic.
So to me it looks impractical and more confusing than
helpful.

Wes

P.S. - As for whether this is the right place or whether
anyone replies to a message, that is all purely consensual.
No one is obliged to answer anyone's email.  There is
a general obligation on the part of the committers to
participate in discussions on aspectj-dev pertaining to
the *development* of the technology, but aspectj-users is
for users to communicate with each other.  If people
require immediate support when writing AspectJ code,
they can solicit professional support here or on
aspectj-dev.  (It's generally considered improper for
those offering support services to solicit people who
post to mailing lists unless the posters explicitly
request professional support.)  Also, emails on
questions that can't be resolved by considering the
documentation tend to spark more interest, as do emails
from posters who in the past have contributed correct
and well- written questions and answers.

Konstantin Knizhnik wrote:

Hello,

Three days ago I have sent the question to this mailing list about
possibility to distinguish access to this and foreign
objects with AspectJ pointcuts. I received no replies to my message.
I wonder if this mailing list is the right place for asking such
questions? Its it really checked by Aspect-J developers?

I briefly repeat my message here. To be able to efficiently implement
persistence and remoting aspects, it will be very useful to be able to
distinguish access to self instance fields and access to fields of
other objects (non-this access). In last case, such accesses should be
wrapped with advice code which is responsible for object loading.
But there is completely no need to insert such code for access to self
instance variables. Right now I find only one way how to express
correspondent pointcut in AspectJ: comparing result of this() and
target(). But it is translated by AspectJ in runtime check! So it is
in any case impossible to avoid AOP overhead for accessing self
instance fields.

Actually what I want to know
1. Is such feature currently supported by Aspect-J?
2. If not - what is the reason:
- nobody requested such feature before
- technical problems with implementing this feature (it seems to me
that there are completely no problems)
- some ideological arguments against adding this feature
- this feature will not be used by most of Aspect-J users
- performance is not critical for most of Aspect-J users.
3. Also are there plans to implement it in 1.2 version of Aspect-J?




Back to the top