Bug 104810 - should advice calls be matched by call pointcuts in annotation style (and similar scenarios)
Summary: should advice calls be matched by call pointcuts in annotation style (and sim...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: All All
: P3 major with 1 vote (vote)
Target Milestone: 1.6.8   Edit
Assignee: Alexandre Vasseur CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-22 11:02 EDT by Alexandre Vasseur CLA
Modified: 2010-01-12 20:00 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Vasseur CLA 2005-07-22 11:02:10 EDT
check delta between Aj and @aj
(infinite recursion)
Comment 1 Alexandre Vasseur CLA 2005-07-25 09:52:23 EDT
@advice execution match by execution ?: should not pick advice execution
- OK (see BcelClassWeaver.match(LazyMethoGen)
- KO (the pointcut parser will match, not looking if it is a @advice)
(should fix the pointcut parser)
=> TODO

@advice call match by call ?: should not pick call to @advice (since in aj user
cannot call advice explicitly) [or should they - that s debatable...]
[+ meta-aspect, and @Aspect are actually java class anyway]
- Now: it match
- If to not match: should fix SignaturePattern
(ie the grammar itself must say no match for f.e. 3rd party tools using the
pointcut parser directly and not the weaver)
=> TODO

@aspect aspectof match by call/execution ?
call cannot be made on src @aspect (needs Aspects.aspectOf reflective) but might
be made on ajc @aspect since aspectof is introduced
- need to check this one
(signature pattern aspectOf and decl type is @Aspect or something like that,
both for call and execution - providing code style does the same and skip
aspectOf() call/execution matching
=> TODO




Comment 2 Adrian Colyer CLA 2005-08-15 12:18:18 EDT
@advice execution match by execution ?: should not pick advice execution

-> the execution of advice should not be matched by an execution join point. It
*should* be matched by an adviceexecution join point.  We lose the nice ability
to match on name, parameters etc., but that should be fixed by extending the
adviceexecution form to allow this (maybe post 1.5) rather than giving the wrong
kind of join point.

@advice call match by call ?: should not pick call to @advice (since in aj user
cannot call advice explicitly) [or should they - that s debatable...]

-> interesting. In a code-style aspect program there is simply no way to call
advice, so this can't happen. In an @AJ style program there is a very simple way
to call advice. We once talked about having a special Checker (declare error) in
the weaver that matched on any call to a method annotated with @advice. This
would give the exact same capabilities as code-style, but it seems a bit
draconian when direct calling makes it easy to write unit tests and I don't want
to forbid that. I'm tempted to say that if you do explicitly call an "advice"
you *do* get a call join point.

@aspect aspectof match by call/execution ?
-> calls should match as per the users program (so a piece of user code
MyAspect.aspectOf() is a call to call(* aspectOf(..)), but the aspectOf calls
inserted as part of the weaving process are *not* matched. A call to
Aspects.aspectOf(..) should be matched by a call pcd matching that signature (no
special fudging). We don't support execution join points for aspectOf, should
probably do the same for Aspects.aspectOf ? (if for no other reason than weaving
aspectOf can really screw up weaving!)
Comment 3 Alexandre Vasseur CLA 2005-08-16 11:36:41 EDT
ok thanks

note: Aspects.aspectOf can only have call jp as it is in org.aspectj.*
I was talking only about the weaved in (compiled in) aspectOf(..) method in the
advice - so this one does not gets matched for execution jp, and **does** get
matched for call jp when the call is not one that we weaved in.

Since for @AJ aspect, the aspectOf() is called
- wether from Aspects.aspectOf, reflectively
- wether directly if aspect was available in binary form
this might mean some idiom to match them in both case - unfortunately, + some
more invasive pointcut to match Aspects.aspectOf(..) on the aspect I am
interested in only.
(correct me if this is wrong)

Comment 4 Adrian Colyer CLA 2005-09-27 05:53:39 EDT
raising to P2
Comment 5 Adrian Colyer CLA 2005-12-14 07:07:40 EST
moving out beyond the RC, we need to put something out!
Comment 6 Andrew Clement CLA 2006-06-27 10:34:09 EDT
really must make a decision on this !
Comment 7 Andrew Clement CLA 2006-09-25 11:08:19 EDT
...
Comment 8 Ron Bodkin CLA 2009-04-07 14:40:19 EDT
It appears that adviceexecution pointcuts still don't match annotation-defined advice. That's a real problem if you are relying on adviceexecution to match, e.g., it causes problems for those using annotation aspects to extend Glassbox.
Comment 9 Andrew Clement CLA 2009-04-07 14:48:49 EDT
resurrection
Comment 10 Andrew Clement CLA 2009-04-08 15:11:06 EDT
I just wrote this program
-- A.java --
import org.aspectj.lang.annotation.*;

@Aspect
public class A {

  public void m() {
  }

  @Before("adviceexecution()")
  public void advice() {

  }
}

aspect B {

  before(): adviceexecution() {}
}
------------

And it worked as expected: ajc -1.5 A.java -showWeaveInfo

Join point 'adviceexecution(void B.ajc$before$B$1$1ff5cffd())' in Type 'B' (A.java:17) advised by before advice from 'B' (A.java:17)

Join point 'adviceexecution(void B.ajc$before$B$1$1ff5cffd())' in Type 'B' (A.java:17) advised by before advice from 'A' (A.java:10)

Join point 'adviceexecution(void A.advice())' in Type 'A' (A.java:10) advised by before advice from 'B' (A.java:17)

Join point 'adviceexecution(void A.advice())' in Type 'A' (A.java:10) advised by before advice from 'A' (A.java:10)

So what isn't working?
Comment 11 Andrew Clement CLA 2010-01-12 20:00:35 EST
appears to be working from my most recent comment, will revisit if this comes up again