Bug 30439 - spurious "circular dependency" error
Summary: spurious "circular dependency" error
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P4 minor (vote)
Target Milestone: 1.2.1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 30438 40655 57993 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-01-28 16:20 EST by Doug Orleans CLA
Modified: 2004-10-21 04:32 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 Doug Orleans CLA 2003-01-28 16:20:10 EST
AspectJ Compiler 1.1beta4
This program:

aspect Foo { 
  pointcut p1(): execution(void f()) && cflow(execution(void f1()));
  pointcut p2(): execution(void f()) && cflow(execution(void f2()));

  before(): p1() { }
  after():  p1() { }
  before(): p2() { }
  after():  p2() { }
}

class A {
  void f1() { f(); }
  void f2() { f(); }
  void f() { }
}

results in these errors:

circular dependency at method-execution(void A.f())
circular dependency at method-execution(void A.f())
circular dependency at method-execution(void A.f())
circular dependency at method-execution(void A.f())

4 errors

If I comment out any one of the four pieces of advice, all the errors go away.
Also, assuming that there is a valid reason for printing this error sometimes, how come there's no line number?

--Doug
Comment 1 Doug Orleans CLA 2003-01-28 16:22:36 EST
*** Bug 30438 has been marked as a duplicate of this bug. ***
Comment 2 Jim Hugunin CLA 2003-01-29 12:06:30 EST
The error message needs much work.  It should say something closer to:
  can't determine precedence between two pieces of advice that apply to the 
same join point (method-execution(void A.f()))
  after@2 > before@1 > before@3 > after@2
I'll leave this as a bug until the error message is improved; however, 
otherwise the compiler is correct to prohibit this particular aspect

You should be able to fix this problem by grouping both of your after advice 
together lexically, i.e.
before p1
before p2
after p1
after p2

The reasons for this are fairly complicated, but have to do with the rules for
ordering multiple pieces of advice that can apply to the same join point.  See 
the section on "Advice precedence" in the semantics secton of the programming 
guide for what might be an explanation.  If you still don't fully understand 
or agree with the issue, please send a message to aspectj-users and either 
Erik or I will explain in more detail.
Comment 3 Jim Hugunin CLA 2003-02-13 12:39:10 EST
Lowering priority and severity as this is only about a better error message.
Comment 4 Jim Hugunin CLA 2003-07-23 13:20:53 EDT
*** Bug 40655 has been marked as a duplicate of this bug. ***
Comment 5 Adrian Colyer CLA 2004-07-29 10:55:09 EDT
This program now outputs the following:

/home/colyer/tmp/Doug.java:5 error can't determine precedence between two or 
more pieces of advice that apply the same join point: method-execution(void A.
f())
before(): p1() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:6 error can't determine precedence between two or 
more pieces of advice that apply the same join point: method-execution(void A.
f())
after():  p1() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:7 error can't determine precedence between two or 
more pieces of advice that apply the same join point: method-execution(void A.
f())
before(): p2() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:8 error can't determine precedence between two or 
more pieces of advice that apply the same join point: method-execution(void A.
f())
after():  p2() { }
^^^^^^^^^^^
	

4 errors

Will close the defect once this is available in a published build.
Comment 6 Adrian Colyer CLA 2004-07-29 11:17:19 EDT
*** Bug 57993 has been marked as a duplicate of this bug. ***
Comment 7 Adrian Colyer CLA 2004-07-29 13:12:26 EDT
The even better version...

/home/colyer/tmp/Doug.java:5 [error] can't determine precedence between two or 
more pieces of advice that apply to the same join point: method-execution(void 
A.f())
before(): p1() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:6 [error] can't determine precedence between two or 
more pieces of advice that apply to the same join point: method-execution(void 
A.f())
after():  p1() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:7 [error] can't determine precedence between two or 
more pieces of advice that apply to the same join point: method-execution(void 
A.f())
before(): p2() { }
^^^^^^^^^^^
	
/home/colyer/tmp/Doug.java:8 [error] can't determine precedence between two or 
more pieces of advice that apply to the same join point: method-execution(void 
A.f())
after():  p2() { }
^^^^^^^^^^^
	

4 errors


Thanks :)
Comment 8 Adrian Colyer CLA 2004-07-30 03:21:37 EDT
Fix now available from AspectJ download page.
Comment 9 Adrian Colyer CLA 2004-10-21 04:32:39 EDT
Fix released as part of AspectJ 1.2.1