diff options
author | aclement <aclement> | 2004-08-09 10:26:53 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-08-09 10:26:53 +0000 |
commit | 851da68a07bcbfac4414fadc1b9f3bc02fa810a5 (patch) | |
tree | 8774e959f018037db9891f447e4f7070c0cc8a71 /tests | |
parent | 299d24a82619057d3746db391afb238c213d56e5 (diff) | |
download | aspectj-851da68a07bcbfac4414fadc1b9f3bc02fa810a5.tar.gz aspectj-851da68a07bcbfac4414fadc1b9f3bc02fa810a5.zip |
Fix for Bug 71377: Cannot advise private method call in around advice
Diffstat (limited to 'tests')
5 files changed, 202 insertions, 2 deletions
diff --git a/tests/bugs/AroundAdviceJPs/FieldGetJoinPointsInAroundAdvice.java b/tests/bugs/AroundAdviceJPs/FieldGetJoinPointsInAroundAdvice.java new file mode 100644 index 000000000..950cc1604 --- /dev/null +++ b/tests/bugs/AroundAdviceJPs/FieldGetJoinPointsInAroundAdvice.java @@ -0,0 +1,62 @@ +import java.util.*; + +public aspect FieldGetJoinPointsInAroundAdvice { + + private static int secretField1; + private int secretField2; + public static int nonsecretField3; + public int nonsecretField4; + + + static int privateNonstaticFieldGets = 0; + static int privateStaticFieldGets = 0; + static int publicNonstaticFieldGets = 0; + static int publicStaticFieldGets = 0; + + before () : cflow(adviceexecution()) && get(private !static * *secret*) { privateNonstaticFieldGets++; tjps.add(thisJoinPoint.getSourceLocation());} + before () : cflow(adviceexecution()) && get(private static * *secret*) { privateStaticFieldGets++;} + before () : cflow(adviceexecution()) && get(public !static * *secret*) { publicNonstaticFieldGets++;} + before () : cflow(adviceexecution()) && get(public static * *secret*) { publicStaticFieldGets++;} + + pointcut execTest () : execution(* FieldGetJoinPointsInAroundAdvice.test()); + + before () : execTest() { + int i = secretField1; + i=secretField2; + i=nonsecretField3; + i=nonsecretField4; + } + + void around () : execTest() { + int i=secretField1; + i=secretField2; + i=nonsecretField3; + i=nonsecretField4; + proceed(); + } + + after () : execTest () { + int i=secretField1; + i=secretField2; + i=nonsecretField3; + i=nonsecretField4; + } + + private static List tjps = new ArrayList(); + + public static void test () { + System.out.println("? test()"); + } + + public static void main (String[] args) { + test(); + if (privateNonstaticFieldGets!=privateStaticFieldGets || + privateStaticFieldGets!=publicStaticFieldGets || + publicStaticFieldGets!=publicNonstaticFieldGets) throw new RuntimeException( + "\n privateNonstaticFieldGets="+privateNonstaticFieldGets+ + "\n publicNonstaticFieldGets="+publicNonstaticFieldGets+ + "\n privateStaticFieldGets="+privateStaticFieldGets+ + "\n publicStaticFieldGets="+publicStaticFieldGets); + //System.err.println(tjps); + } +}
\ No newline at end of file diff --git a/tests/bugs/AroundAdviceJPs/FieldJoinPointsInAroundAdvice.java b/tests/bugs/AroundAdviceJPs/FieldJoinPointsInAroundAdvice.java new file mode 100644 index 000000000..7d92d1322 --- /dev/null +++ b/tests/bugs/AroundAdviceJPs/FieldJoinPointsInAroundAdvice.java @@ -0,0 +1,62 @@ +import java.util.*; + +public aspect FieldJoinPointsInAroundAdvice { + + private static int secretField1; + private int secretField2; + public static int nonsecretField3; + public int nonsecretField4; + + + static int privateNonstaticFieldSets = 0; + static int privateStaticFieldSets = 0; + static int publicNonstaticFieldSets = 0; + static int publicStaticFieldSets = 0; + + before () : cflow(adviceexecution()) && set(private !static * *secret*) { privateNonstaticFieldSets++; tjps.add(thisJoinPoint.getSourceLocation());} + before () : cflow(adviceexecution()) && set(private static * *secret*) { privateStaticFieldSets++; tjps.add(thisJoinPoint.getSourceLocation());} + before () : cflow(adviceexecution()) && set(public !static * *secret*) { publicNonstaticFieldSets++;} + before () : cflow(adviceexecution()) && set(public static * *secret*) { publicStaticFieldSets++;} + + pointcut execTest () : execution(* FieldJoinPointsInAroundAdvice.test()); + + before () : execTest() { + secretField1++; + secretField2++; + nonsecretField3++; + nonsecretField4++; + } + + void around () : execTest() { + secretField1++; + secretField2++; + nonsecretField3++; + nonsecretField4++; + proceed(); + } + + after () : execTest () { + secretField1++; + secretField2++; + nonsecretField3++; + nonsecretField4++; + } + + private static List tjps = new ArrayList(); + + public static void test () { + System.out.println("? test()"); + } + + public static void main (String[] args) { + test(); + if (privateNonstaticFieldSets!=privateStaticFieldSets || + privateStaticFieldSets!=publicStaticFieldSets || + publicStaticFieldSets!=publicNonstaticFieldSets) throw new RuntimeException( + "\n privateNonstaticFieldSets="+privateNonstaticFieldSets+ + "\n publicNonstaticFieldSets="+publicNonstaticFieldSets+ + "\n privateStaticFieldSets="+privateStaticFieldSets+ + "\n publicStaticFieldSets="+publicStaticFieldSets); + //System.err.println(tjps); + } +}
\ No newline at end of file diff --git a/tests/bugs/AroundAdviceJPs/JoinPointInAroundAdvice.java b/tests/bugs/AroundAdviceJPs/JoinPointInAroundAdvice.java new file mode 100644 index 000000000..db8ba6b24 --- /dev/null +++ b/tests/bugs/AroundAdviceJPs/JoinPointInAroundAdvice.java @@ -0,0 +1,44 @@ +import java.util.*; + +public aspect JoinPointInAroundAdvice { + + static int i = 0; + static int j = 0; + + before () : call(* JoinPointInAroundAdvice.privateMethod(..)) { i++; tjps.add(thisJoinPoint.getSourceLocation());} + before () : call(* JoinPointInAroundAdvice.publicMethod(..)) { j++;} + + pointcut execTest () : execution(* JoinPointInAroundAdvice.test()); + + before () : execTest() { + privateMethod("before"); + publicMethod("before"); + } + + void around () : execTest() { + privateMethod("around"); + publicMethod("around"); + proceed(); + } + + after () : execTest () { + privateMethod("after"); + publicMethod("after"); + } + + private static List tjps = new ArrayList(); + + private static void privateMethod(String from) { }//System.out.println("? privateMethod() " + from); } + public static void publicMethod(String from) { }//System.out.println("? publicMethod() " + from); } + + public static void test () { + System.out.println("? test()"); + } + + public static void main (String[] args) { + test(); + if (i!=j || i!=3) throw new RuntimeException("Missing join point: private="+i+" public="+j); + //System.err.println(tjps); + } +} + diff --git a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java index abaf4d5d5..32eb250b9 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java @@ -25,7 +25,7 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void test001(){ - runTest("false ambigous binding error (introduced in 1.2rc2)"); + runTest("false ambiguous binding error (introduced in 1.2rc2)"); } public void test002(){ @@ -99,5 +99,20 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase { assertTrue("Expected to find [s32767] in this output but didn't:"+output,output.indexOf("[s32767]")!=-1); assertTrue("Expected to find [b0] in this output but didn't:"+output,output.indexOf("[b0]")!=-1); } + + public void test017_PrivateMethodCallsInAroundAdvice() { + runTest("Cannot advise private method call in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } + + public void test018_PrivateFieldSetsInAroundAdvice() { + runTest("Cannot advise private field sets in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } + + public void test019_PrivateFieldGetsInAroundAdvice() { + runTest("Cannot advise private field gets in around advice"); + System.err.println(getLastRunResult().getStdErr()); + } } diff --git a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml index 02d1acb97..8d2f21453 100644 --- a/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml @@ -2,7 +2,7 @@ <ajc-test dir="bugs" - pr="62073" title="false ambigous binding error (introduced in 1.2rc2)"> + pr="62073" title="false ambiguous binding error (introduced in 1.2rc2)"> <compile files="DisjunctVarBinding_2.java,DisjunctVarBinding_3.java"> <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type B"/> <message kind="error" line="25" file="DisjunctVarBinding_2.java" text="Ambiguous binding of type A"/> @@ -138,3 +138,20 @@ <run class="NoByteToInt"/> </ajc-test> + <ajc-test dir="bugs/AroundAdviceJPs" pr="71377" + title="Cannot advise private method call in around advice"> + <compile files="JoinPointInAroundAdvice.java"/> + <run class="JoinPointInAroundAdvice"/> + </ajc-test> + + <ajc-test dir="bugs/AroundAdviceJPs" pr="71377" + title="Cannot advise private field sets in around advice"> + <compile files="FieldJoinPointsInAroundAdvice.java"/> + <run class="FieldJoinPointsInAroundAdvice"/> + </ajc-test> + + <ajc-test dir="bugs/AroundAdviceJPs" pr="71377" + title="Cannot advise private field gets in around advice"> + <compile files="FieldGetJoinPointsInAroundAdvice.java"/> + <run class="FieldGetJoinPointsInAroundAdvice"/> + </ajc-test>
\ No newline at end of file |