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/bugs | |
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/bugs')
3 files changed, 168 insertions, 0 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); + } +} + |