Browse Source

126167: Fix for @Around problems...

tags/V1_5_2rc1
aclement 18 years ago
parent
commit
718543f8d7

+ 1
- 1
tests/features151/ataround/A1.java View File

@@ -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) {

+ 1
- 1
tests/features151/ataround/A10.java View File

@@ -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) {

+ 32
- 0
tests/features151/ataround/A42.java View File

@@ -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); }
}

+ 27
- 4
tests/features151/ataround/A7.java View File

@@ -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); }

}
*/

+ 2
- 2
tests/features151/ataround/A9.java View File

@@ -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) {

+ 33
- 0
tests/features151/ataround/Break1.java View File

@@ -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); }
}

+ 38
- 0
tests/features151/ataround/Break2.java View File

@@ -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); }

}

+ 4
- 1
tests/features151/ataround/BugCase1.java View File

@@ -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);

+ 5
- 2
tests/features151/ataround/BugCase2.java View File

@@ -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);

+ 9
- 8
tests/features151/ataround/MultipleArgs.java View File

@@ -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});
}

+ 30
- 0
tests/features151/ataround/X42.java View File

@@ -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); }
}

+ 204
- 58
tests/src/org/aspectj/systemtest/ajc151/ataround.xml View File

@@ -14,6 +14,16 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - basic - noinline">
<compile files="A1.java" options="-1.5 -XnoInline"/>
<run class="A1">
<stderr>
<line text="advice from ataj aspect"/>
<line text="faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - basic">
<compile files="A1.java" options="-1.5"/>
<run class="A1">
@@ -26,37 +36,8 @@
<ajc-test dir="features151/ataround" title="code style - forget to pass target">
<compile files="X2.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - forget to pass target">
<compile files="A2.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="code style - incorrect arg types">
<compile files="X3.java" options="-1.5">
<message kind="error" line="7" text="Type mismatch: cannot convert from String to M"/>
<message kind="error" line="7" text="Type mismatch: cannot convert from M to String"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - incorrect arg types">
<compile files="A3.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="code style - correct usage, binding and passing new target for call">
<ajc-test dir="features151/ataround" title="code style - correct usage, binding and passing same target for call">
<compile files="X4.java" options="-1.5"/>
<run class="X4">
<stderr>
@@ -66,7 +47,17 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing new target for call">
<ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing same target for call - noinline">
<compile files="A4.java" options="-1.5 -XnoInline"/>
<run class="A4">
<stderr>
<line text="advice from ataj aspect"/>
<line text="1faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing same target for call">
<compile files="A4.java" options="-1.5"/>
<run class="A4">
<stderr>
@@ -78,9 +69,10 @@
<ajc-test dir="features151/ataround" title="code style - changing target for call">
<compile files="X5.java" options="-1.5"/>
<run class="X5">
<ajc-test dir="features151/ataround" title="code style - correct usage, binding and passing new target for call">
<compile files="X42.java" options="-1.5"/>
<run class="X42">
<stderr>
<line text="advice from code aspect"/>
<line text="2faked"/>
@@ -88,9 +80,9 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - changing target for call">
<compile files="A5.java" options="-1.5"/>
<run class="A5">
<ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing new target for call - noinline">
<compile files="A42.java" options="-1.5 -XnoInline"/>
<run class="A42">
<stderr>
<line text="advice from ataj aspect"/>
<line text="2faked"/>
@@ -98,21 +90,9 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="code style - changing target for call - reverse order">
<compile files="X6.java" options="-1.5"/>
<run class="X6">
<stderr>
<line text="advice from code aspect"/>
<line text="2faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - changing target for call - reverse order">
<compile files="A6.java" options="-1.5"/>
<run class="A6">
<ajc-test dir="features151/ataround" title="annotation style - correct usage, binding and passing new target for call">
<compile files="A42.java" options="-1.5"/>
<run class="A42">
<stderr>
<line text="advice from ataj aspect"/>
<line text="2faked"/>
@@ -122,6 +102,23 @@
<ajc-test dir="features151/ataround" title="code style - forget to pass target">
<compile files="X2.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - forget to pass target">
<compile files="A2.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="code style - bind this on call - change on proceed - no effect">
<compile files="X7.java" options="-1.5"/>
<run class="X7">
@@ -132,6 +129,16 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this on call - change on proceed - no effect - noinline">
<compile files="A7.java" options="-1.5 -XnoInline"/>
<run class="A7">
<stderr>
<line text="advice from ataj aspect"/>
<line text="1faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this on call - change on proceed - no effect">
<compile files="A7.java" options="-1.5"/>
<run class="A7">
@@ -154,17 +161,44 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this on execution - change on proceed - works - noinline">
<compile files="A8.java" options="-1.5 -XnoInline"/>
<run class="A8">
<stderr>
<line text="advice from ataj aspect"/>
<line text="2faked"/>
</stderr>
</run>
</ajc-test>

<ajc-test dir="features151/ataround" title="annotation style - bind this on execution - change on proceed - works">
<compile files="A8.java" options="-1.5"/>
<run class="A8">
<stderr>
<line text="advice from code aspect"/>
<line text="advice from ataj aspect"/>
<line text="2faked"/>
</stderr>
</run>
</ajc-test>


<ajc-test dir="features151/ataround" title="code style - incorrect arg types">
<compile files="X3.java" options="-1.5">
<message kind="error" line="7" text="Type mismatch: cannot convert from String to M"/>
<message kind="error" line="7" text="Type mismatch: cannot convert from M to String"/>
</compile>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - incorrect arg types">
<compile files="A3.java" options="-1.5">
<message kind="error" line="7" text="too few arguments to proceed, expected 2"/>
</compile>
</ajc-test>

<ajc-test dir="features151/ataround" title="code style - bind this and target on execution - change on proceed - works">
<compile files="X9.java" options="-1.5"/>
@@ -176,17 +210,29 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this and target on execution - change on proceed - works - noinline">
<compile files="A9.java" options="-1.5 -XnoInline"/>
<run class="A9">
<stderr>
<line text="advice from ataj aspect"/>
<line text="3faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this and target on execution - change on proceed - works">
<compile files="A9.java" options="-1.5"/>
<run class="A9">
<stderr>
<line text="advice from code aspect"/>
<line text="advice from ataj aspect"/>
<line text="3faked"/>
</stderr>
</run>
</ajc-test>


</ajc-test>

<ajc-test dir="features151/ataround" title="code style - bind this and target on call - change on proceed - works">
<compile files="X10.java" options="-1.5"/>
@@ -198,15 +244,115 @@
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - bind this and target on call - change on proceed - works - noinline">
<compile files="A10.java" options="-1.5"/>
<run class="A10">
<stderr>
<line text="advice from ataj aspect"/>
<line text="3faked"/>
</stderr>
</run>
</ajc-test>

<ajc-test dir="features151/ataround" title="annotation style - bind this and target on call - change on proceed - works">
<compile files="A10.java" options="-1.5"/>
<run class="A10">
<stderr>
<line text="advice from code aspect"/>
<line text="advice from ataj aspect"/>
<line text="3faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="breaking it - one">
<compile files="Break1.java" options="-1.5"/>
<run class="Break1">
<stderr>
<line text="advice from ataj aspect"/>
<line text="1faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="breaking it - two">
<compile files="Break2.java" options="-1.5"/>
<run class="Break2">
<stderr>
<line text="advice from ataj aspect"/>
<line text="1faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="bug case one">
<compile files="BugCase1.java" options="-1.5"/>
<run class="BugCase1">
<stderr>
<line text="advice running"/>
<line text="Setting age to 10"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="bug case two">
<compile files="BugCase2.java" options="-1.5"/>
<run class="BugCase2">
<stderr>
<line text="advice running"/>
<line text="Setting age to 10"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="multiple args">
<compile files="MultipleArgs.java" options="-1.5"/>
<run class="MultipleArgs">
<stderr>
<line text="advice running"/>
<line text="advice running"/>
<line text="advice running"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="code style - changing target for call - reverse order">
<compile files="X6.java" options="-1.5"/>
<run class="X6">
<stderr>
<line text="advice from code aspect"/>
<line text="2faked"/>
</stderr>
</run>
</ajc-test>
<ajc-test dir="features151/ataround" title="annotation style - changing target for call - reverse order">
<compile files="A6.java" options="-1.5"/>
<run class="A6">
<stderr>
<line text="advice from ataj aspect"/>
<line text="2faked"/>
</stderr>
</run>
</ajc-test>







Loading…
Cancel
Save