From: aclement Date: Fri, 23 Jun 2006 12:22:54 +0000 (+0000) Subject: 126167: Fix for @Around problems... X-Git-Tag: V1_5_2rc1~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=718543f8d7bdeec644aaee560066abd4a623578c;p=aspectj.git 126167: Fix for @Around problems... --- diff --git a/tests/features151/ataround/A1.java b/tests/features151/ataround/A1.java index 669051759..920ee1a04 100644 --- a/tests/features151/ataround/A1.java +++ b/tests/features151/ataround/A1.java @@ -8,7 +8,7 @@ public class A1 { @Around("call(void M.method(String)) && args(p)") public void a( ProceedingJoinPoint pjp, String p) throws Throwable { System.err.println("advice from ataj aspect"); - pjp.proceed( new Object[] { pjp.getTarget(),"faked" } ); + pjp.proceed( new Object[] { "faked" } ); } public static void main(String []argv) { diff --git a/tests/features151/ataround/A10.java b/tests/features151/ataround/A10.java index 0ef445502..77ad30ece 100644 --- a/tests/features151/ataround/A10.java +++ b/tests/features151/ataround/A10.java @@ -10,7 +10,7 @@ public class A10 { @Around("call(void M.method(String)) && args(p) && this(t) && target(t2)") public void a( ProceedingJoinPoint pjp, M t,String p, M t2) throws Throwable { System.err.println("advice from ataj aspect"); - pjp.proceed(new Object[]{newM2,"faked",newM3}); + pjp.proceed(new Object[]{newM2,newM3,"faked"}); } public static void main(String []argv) { diff --git a/tests/features151/ataround/A42.java b/tests/features151/ataround/A42.java new file mode 100644 index 000000000..d6222be73 --- /dev/null +++ b/tests/features151/ataround/A42.java @@ -0,0 +1,32 @@ +// Bind the target and pass in the right order +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; + +@Aspect +public class A42 { + M newM = new M("2"); + + @Around("call(void M.method(String)) && args(p) && target(t)") + public void a( ProceedingJoinPoint pjp, M t, String p) throws Throwable { + System.err.println("advice from ataj aspect"); + pjp.proceed(new Object[]{newM,"faked"}); + } + + public static void main(String []argv) { + M.main(argv); + } +} + +class M { + + String prefix; + + public M(String prefix) { this.prefix = prefix; } + + public static void main( String[] args ) { + M m = new M("1"); + m.method("real"); + } + + public void method(String s) { System.err.println(prefix+s); } +} diff --git a/tests/features151/ataround/A7.java b/tests/features151/ataround/A7.java index 0a207434f..6daf99524 100644 --- a/tests/features151/ataround/A7.java +++ b/tests/features151/ataround/A7.java @@ -4,19 +4,41 @@ import org.aspectj.lang.annotation.*; @Aspect public class A7 { - M newM = new M("2"); + N newN = new N(); @Around("call(void M.method(String)) && args(p) && this(t)") - public void a( ProceedingJoinPoint pjp, M t,String p) throws Throwable { + public void a( ProceedingJoinPoint pjp, N t,String p) throws Throwable { System.err.println("advice from ataj aspect"); - pjp.proceed(new Object[]{newM,"faked"}); + pjp.proceed(new Object[]{newN,"faked"}); } public static void main(String []argv) { - M.main(argv); + N.main(argv); } } +class N { + public static void main( String[] args ) { + N n = new N(); + n.methodCaller("real"); + } + + + public void methodCaller(String param) { + M m = new M("1"); + m.method(param); + } + +} + + +class M { + String prefix; + public M(String prefix) { this.prefix = prefix; } + public void method(String s) { System.err.println(prefix+s); } +} + +/* class M { String prefix; @@ -35,3 +57,4 @@ class M { public void method(String s) { System.err.println(prefix+s); } } +*/ diff --git a/tests/features151/ataround/A9.java b/tests/features151/ataround/A9.java index 97bf674ba..0352625f1 100644 --- a/tests/features151/ataround/A9.java +++ b/tests/features151/ataround/A9.java @@ -8,9 +8,9 @@ public class A9 { M newM3 = new M("3"); @Around("execution(void M.method(String)) && args(p) && this(t) && target(t2)") - public void a( ProceedingJoinPoint pjp, M t,String p, M t2) throws Throwable { + public void a( ProceedingJoinPoint pjp, M t,M t2,String p) throws Throwable { System.err.println("advice from ataj aspect"); - pjp.proceed(new Object[]{newM2,"faked",newM3}); + pjp.proceed(new Object[]{newM2,newM3,"faked"}); } public static void main(String []argv) { diff --git a/tests/features151/ataround/Break1.java b/tests/features151/ataround/Break1.java new file mode 100644 index 000000000..c3dbc7262 --- /dev/null +++ b/tests/features151/ataround/Break1.java @@ -0,0 +1,33 @@ +// target() is used, but not in a binding capacity, so dont need to supply +// in proceed + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; + +@Aspect +public class Break1 { + + @Around("call(void M.method(String)) && args(p) && target(M)") + public void a( ProceedingJoinPoint pjp, String p) throws Throwable { + System.err.println("advice from ataj aspect"); + pjp.proceed(new Object[]{"faked"}); + } + + public static void main(String []argv) { + M.main(argv); + } +} + +class M { + + String prefix; + + public M(String prefix) { this.prefix = prefix; } + + public static void main( String[] args ) { + M m = new M("1"); + m.method("real"); + } + + public void method(String s) { System.err.println(prefix+s); } +} diff --git a/tests/features151/ataround/Break2.java b/tests/features151/ataround/Break2.java new file mode 100644 index 000000000..c035a1535 --- /dev/null +++ b/tests/features151/ataround/Break2.java @@ -0,0 +1,38 @@ +// this() is used for matching but not binding +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; + +@Aspect +public class Break2 { + M newM2 = new M("2"); + M newM3 = new M("3"); + + @Around("execution(void M.method(String)) && args(p) && this(M)") + public void a( ProceedingJoinPoint pjp, String p) throws Throwable { + System.err.println("advice from ataj aspect"); + pjp.proceed(new Object[]{"faked"}); + } + + public static void main(String []argv) { + M.main(argv); + } +} + +class M { + + String prefix; + + public M(String prefix) { this.prefix = prefix; } + + public static void main( String[] args ) { + M m = new M("1"); + m.methodCaller("real"); + } + + public void methodCaller(String param) { + method(param); + } + + public void method(String s) { System.err.println(prefix+s); } + +} diff --git a/tests/features151/ataround/BugCase1.java b/tests/features151/ataround/BugCase1.java index 4f1c01a34..9de1307e6 100644 --- a/tests/features151/ataround/BugCase1.java +++ b/tests/features151/ataround/BugCase1.java @@ -12,11 +12,14 @@ public class BugCase1 { System.err.println("advice running"); return thisJoinPoint.proceed(new Object[]{i*2}); } + public static void main(String []argv) { + Foo.main(argv); + } } -public class Foo { +class Foo { int a; public void setAge(int i) { System.err.println("Setting age to "+i); diff --git a/tests/features151/ataround/BugCase2.java b/tests/features151/ataround/BugCase2.java index f99833e06..e12cb6e4e 100644 --- a/tests/features151/ataround/BugCase2.java +++ b/tests/features151/ataround/BugCase2.java @@ -2,7 +2,7 @@ import org.aspectj.lang.*; import org.aspectj.lang.annotation.*; @Aspect -public class ProceedAspect { +public class BugCase2 { @Pointcut("execution(* setAge(..)) && args(i)") void setAge(int i) {} @@ -12,10 +12,13 @@ public class ProceedAspect { System.err.println("advice running"); return thisJoinPoint.proceed(new Object[]{i*2}); } + public static void main(String []argv) { + Foo.main(argv); + } } -public class Foo { + class Foo { int a; public void setAge(int i) { System.err.println("Setting age to "+i); diff --git a/tests/features151/ataround/MultipleArgs.java b/tests/features151/ataround/MultipleArgs.java index b9c5b8f6e..232f13ece 100644 --- a/tests/features151/ataround/MultipleArgs.java +++ b/tests/features151/ataround/MultipleArgs.java @@ -1,24 +1,25 @@ - +import java.util.*; import org.aspectj.lang.annotation.*; +import org.aspectj.lang.*; @Aspect -public class X { +public class MultipleArgs { - @Before("call(* callone(..)) && !within(X) && args(a,b,c)") - public void b1(ProceedingJoinPoint pjp,int a,String b,List c) { + @Around("call(* callone(..)) && !within((MultipleArgs)) && args(a,b,c)") + public void a1(ProceedingJoinPoint pjp,int a,String b,List c) { System.err.println("advice running"); pjp.proceed(new Object[]{a,b,c}); } - @Before("call(* calltwo(..)) && !within(X) && args(a,b,c)") - public void b1(ProceedingJoinPoint pjp,String b,List c,int a) { + @Around("call(* calltwo(..)) && !within((MultipleArgs)) && args(a,b,c)") + public void a2(ProceedingJoinPoint pjp,String b,List c,int a) { System.err.println("advice running"); pjp.proceed(new Object[]{a,b,c}); } - @Before("call(* callone(..)) && !within(X) && args(a,b,c) && this(o)") - public void b1(ProceedingJoinPoint pjp,int a,String b,List c,Object o) { + @Around("call(* callone(..)) && !within((MultipleArgs)) && args(a,b,c) && this(o)") + public void a3(ProceedingJoinPoint pjp,int a,String b,List c,Object o) { System.err.println("advice running"); pjp.proceed(new Object[]{o,a,b,c}); } diff --git a/tests/features151/ataround/X42.java b/tests/features151/ataround/X42.java new file mode 100644 index 000000000..45da120e2 --- /dev/null +++ b/tests/features151/ataround/X42.java @@ -0,0 +1,30 @@ +// Bind the target and pass in the right order + +aspect X42 { + M newM = new M("2"); + + void around(M t,String p): call(void M.method(String)) && args(p) && target(t) { + System.err.println("advice from code aspect"); + proceed( newM , "faked" ); + } + + public static void main(String []argv) { + M.main(argv); + } +} + + + +class M { + + String prefix; + + public M(String prefix) { this.prefix = prefix; } + + public static void main( String[] args ) { + M m = new M("1"); + m.method("real"); + } + + public void method(String s) { System.err.println(prefix+s); } +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/ataround.xml b/tests/src/org/aspectj/systemtest/ajc151/ataround.xml index f52d380b2..d8b625823 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/ataround.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/ataround.xml @@ -14,6 +14,16 @@ + + + + + + + + + + @@ -26,37 +36,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -66,7 +47,17 @@ - + + + + + + + + + + + @@ -78,9 +69,10 @@ - - - + + + + @@ -88,9 +80,9 @@ - - - + + + @@ -98,21 +90,9 @@ - - - - - - - - - - - - - - - + + + @@ -122,6 +102,23 @@ + + + + + + + + + + + + + + + + + @@ -132,6 +129,16 @@ + + + + + + + + + + @@ -154,17 +161,44 @@ + + + + + + + + + + - + + + + + + + + + + + + + + + + + + @@ -176,17 +210,29 @@ + + + + + + + + + + - + - - - + + + + + @@ -198,15 +244,115 @@ + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +