Bug 238054 - Multiple advised calls on a single line counted as a single advised call
Summary: Multiple advised calls on a single line counted as a single advised call
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.3   Edit
Hardware: All All
: P4 normal (vote)
Target Milestone: ---   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-22 11:16 EDT by Raffi Khatchadourian CLA
Modified: 2008-06-27 18:04 EDT (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 Raffi Khatchadourian CLA 2008-06-22 11:16:02 EDT
If two calls appear on a single line to an advised method, the corresponding advise lists only a single method call being advised. This probably isn't very severe for normal users, but it may be troublesome for developers coding against the AJDT (like myself). Consider the following example:

class A {
	void x() {}
	void y() { x();x();}
}

aspect B {
	before() : call(* A.x()) {}
}

If you right-clicked on the above advice declaration it would only show a single method being advised when there is in fact two.
Comment 1 Andrew Clement CLA 2008-06-27 14:22:55 EDT
The problem here is the map created by AspectJ.  The weaving process is mostly divorced from the compilation process - this ensures the weaver behaves the same when binary weaving as it does when occurring on the backend of compilation.

Here is the AspectJ model for the enclosed program:

=== MODEL STATUS REPORT ========= After a batch build
<root>  [java source file] 
  pr238054.aj  [java source file] TEST_SANDBOX\pr238054.aj:1:
    import declarations  [import reference] 
    A  [class] TEST_SANDBOX\pr238054.aj:1:
      x()  [method] TEST_SANDBOX\pr238054.aj:2:
      y()  [method] TEST_SANDBOX\pr238054.aj:3:
        method-call(void A.x())  [code] TEST_SANDBOX\pr238054.aj:3:
    B  [aspect] TEST_SANDBOX\pr238054.aj:6:
      before(): <anonymous pointcut>  [advice] TEST_SANDBOX\pr238054.aj:7:
=== END OF MODEL REPORT =========
=== RELATIONSHIPS REPORT ========= After a batch build
(targets=1) *pr238054.aj}B&before (advises) *pr238054.aj[A~y?method-call(void A.x())
(targets=1) *pr238054.aj[A~y?method-call(void A.x()) (advised by) *pr238054.aj}B&before
=== END OF RELATIONSHIPS REPORT ==

The relationship 'advises' only points to one method-call shadow.  This is because 99% of the information we communicate between compilation and weaving is the .class file, the only extra little bit is an EclipseSourceContext, but it does not contain the detail right now to solve this problem.  By the time the shadow for each x() is built, we have already gotten rid of the Ast and only have line number information.  So the two shadows appear on the same line.

The solution will be to pass the Ast (or some bit of extra information) across in the EclipseSourceContext for use when building the shadows and discard it as soon as the specific file is woven.  It will increase memory usage and reduce performance when building the shadows - something already slow.
Comment 2 Andrew Clement CLA 2008-06-27 18:04:30 EDT
testcase committed into ModelTests. Currently commented out.  I had half a plan to temporarily use the bytecode offset for the invoke instruction to differentiate the two calls, and although that does lead to a model that looks correct, AJDT has trouble interpreting the offset and throws the user into the middle of nowhere in their source code when navigating.