Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Advice ordering and circular dependencies


Hi Antti,

There is currently an open bug for this issue which recommends an improvement to the compiler messages. For an excellent explanation of the problem please see Bugzilla reports 30439 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=30439  ) and 40655 ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=40655 ).  

Best regards,
George




Antti Karanta <Antti.Karanta@xxxxxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

31/03/2004 11:26

Please respond to
aspectj-users

To
"aspectj-users@xxxxxxxxxxx" <aspectj-users@xxxxxxxxxxx>
cc
Subject
[aspectj-users] Advice ordering and circular dependencies







                                  Hi!

 I am not sure whether this is a bug in the compiler or just something I do
not yet understand about ordering the advice within an aspect.

 Try this:

<-- clip -->

public class Foo {

 public static void main(String[] args) {
   Foo f = new Foo();
   f.aMethod();
 }

 void aMethod() {
   System.out.println("Hello");
 }

}

aspect SampleAspect {

 pointcut myCut(): call(* Foo.*());


 after(): myCut() {
     System.out.println("<<< " + thisJoinPointStaticPart);
 }

 before(): myCut() {
     System.out.println("<<< " + thisJoinPointStaticPart);
 }

 void around(): myCut() {
   System.out.println("---Give the join point " +
              thisJoinPointStaticPart + " permission to proceed");
   proceed();
   System.out.println("---Join point " +
              thisJoinPointStaticPart + " done");
  }

}

</-- clip -->

 This compiles and runs fine. The order of the printed messages is logical
given that the ordering of the advice within the aspect affects their
precedence.

 Now change the order of the before and after advice:

<-- clip -->

aspect SampleAspect {

 pointcut myCut(): call(* Foo.*());

 before(): myCut() {
     System.out.println("<<< " + thisJoinPointStaticPart);
 }

 after(): myCut() {
     System.out.println("<<< " + thisJoinPointStaticPart);
 }

 void around(): myCut() {
   System.out.println("---Give the join point " +
              thisJoinPointStaticPart + " permission to proceed");
   proceed();
   System.out.println("---Join point " +
              thisJoinPointStaticPart + " done");
  }

}

</-- clip -->

 Trying to compile this does not succeed:

> ajc Foo.java
/home/akaranta/temp/aspekti/advicesample/Foo.java:22 circular dependency at
method-call(void Foo.aMethod())
/home/akaranta/temp/aspekti/advicesample/Foo.java:26 circular dependency at
method-call(void Foo.aMethod())
/home/akaranta/temp/aspekti/advicesample/Foo.java:18 circular dependency at
method-call(void Foo.aMethod())

3 errors

 So, is this a bug or is the compiler supposed to act this way? I would think
that the order of the before and after advice in this case should have no
effect...

 Some version info if it is needed:

> ajc -version
AspectJ Compiler 1.1.1

> uname -a
Linux hyperion 2.4.18-4GB #1 Wed Mar 27 13:57:05 UTC 2002 i686 unknown


--
Antti Karanta <Antti.Karanta@xxxxxxxxxxxxxx>
Konsultti
FCS Partners Oyj
ph +358407634648
http://www.fcspartners.fi

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


Back to the top