Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] non-initialization set/get join points

Hi Wes,

This is doable (ignoring "target" for the moment):
   (get(* *) || set(* *)) && !cflow(initialization(new(..))

Yes. this helps - thanks!

- Prohibit writes by other instances and static methods

This one is interesting:

>   before(PrinterStream targ) : target(targ) && fieldWrites() {
>       Object caller = thisJoinPoint.getThis();
>        if (targ != caller) {

Is the reason it differs from the following due to the fact that, for static methods, this = null ??

>   before(Object caller, PrinterStream targ) : this(caller)
>       && target(targ) && fieldWrites() {
>       if (caller != targ) {



Anyway, it looks like a full solution to my problem is possible then!

Style-wise, it is often a mistake to use * for a type pattern
(unless you are otherwise constraining the target types), since
you're simply saying "everything the compiler/weaver can get its hands on" -

Well, my application is profiling and I do want to profile everything the weaver can get its hands on. In fact, I would like to profile rt.jar as well, but this seems largely impractical to me. It just takes too long to weave against the whole jar file.

I think it would nice if the load time weaver could weave against objects from rt.jar. I imagine that this would mean the weaving could be done lazily, which would speed things up.

Cheers,

Dave

i.e., deferring the crosscutting specification
to some build configuration.  We advise folks to write pointcuts
as if the whole world were available, so your code can make sense
and work in implementations where "code the implementation controls"
is everything.

Hope this helps -
Wes


------------Original Message------------
From: David Pearce <david.pearce@xxxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Date: Thu, Nov-11-2004 4:50 PM
Subject: [aspectj-users] non-initialization set/get join points

Hi all,

I have another interesting situation I want express, which I believe is
not possible and I just want to check:

Basically, I want to capture all set/get join points which are not part
of the initialization of the target object. e.g.

class test {
 private int x;
 test() {
  x = 0; // don't want to catch this
 }
}

So, I first thought of the following advice:

before(): (get(* *.*) || set(* *.*)) && !withincode(*.new(..)) {
 ...
}

But. there are two distinct issues with this:

1) it hides sets/gets to one object from within the constructor of another.

2) it does not help in the following case:

class test {
 private int x;
 test() { helperfn(); }
 private helperfn() { x = 0; } // will be caught
}

So. ignoring the first problem, I thought to try and extend my pointcut
as follows:

before(): (get(* *.*) || set(* *.*)) && !withincode(*.new(..)) && !cflow(*.new(..)) {
 ...
}

But. I was surprised to find that this does not compile, because (I believe) cflow needs a definite function (i.e. no "*.").

So, at this point I'm out of ideas. But, is there anything I've missed?

Cheers,

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




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



Back to the top