From: aclement Date: Fri, 13 Aug 2004 15:15:00 +0000 (+0000) Subject: Fix and tests for Bugzilla Bug 71372 X-Git-Tag: V1_2_1~144 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fcdafdbddb66f4ce4046016132addd763353881c;p=aspectj.git Fix and tests for Bugzilla Bug 71372 NoSuchMethodError calling private method from around advice in inner aspect --- diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCall.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall.java new file mode 100644 index 000000000..f1a847d68 --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall.java @@ -0,0 +1,30 @@ + +// In this program, the around advice calls foo() and foo is a private static field in +// class PrivateCall. When compiled the around() advice will be inlined and should call +// foo() through an inline accessor method. +public class PrivateCall { + + public void test () {foo("test");} + + private static void foo (String from) { + System.err.print(":"+from); + } + + public static void main(String[] args) { + new PrivateCall().test(); + } + + private static aspect Aspect { + + pointcut execTest () : + execution(* PrivateCall.test()); + + before () : execTest () { + foo("before"); + } + + void around () : execTest () { + foo("around"); + } + } +} \ No newline at end of file diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCall2.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall2.java new file mode 100644 index 000000000..348c8cd0c --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall2.java @@ -0,0 +1,24 @@ +package abc; + +// This time, the around advice calls the private static method foo but the around advice +// will be inlined into a type in a different package (PrivateCall3). This should work +// as the around advice will call back to the aspect which will call on to foo(). + +public class PrivateCall2 { + + public void test () {foo("test");} + + private static void foo (String from) { + System.err.print(":"+from); + } + + public static void main(String[] args) { + new PrivateCall2().test(); + } + + private static aspect Aspect { + pointcut execTest () : execution(* test()); + before () : execTest () { foo("before"); } + void around () : execTest () { foo("around"); } + } +} \ No newline at end of file diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCall3.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall3.java new file mode 100644 index 000000000..e5da04bf0 --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall3.java @@ -0,0 +1,11 @@ +package def; + +public class PrivateCall3 { + public void test() { + + } + + public static void main(String []argv) { + new PrivateCall3().test(); + } +} \ No newline at end of file diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCallInstance.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCallInstance.java new file mode 100644 index 000000000..96952e1db --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCallInstance.java @@ -0,0 +1,27 @@ +// Similar to PrivateCall but now foo() is a private non-static method. +public class PrivateCallInstance { + + public void test () {foo("test");} + + private void foo (String from) { + System.err.print(":"+from); + } + + public static void main(String[] args) { + new PrivateCallInstance().test(); + } + + private static aspect Aspect { + + pointcut execTest (PrivateCallInstance s) : + execution(* PrivateCallInstance.test()) && target(s); + + before (PrivateCallInstance s) : execTest (s) { + s.foo("before"); + } + + void around (PrivateCallInstance s) : execTest (s) { + s.foo("around"); + } + } +} \ No newline at end of file diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package1.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package1.java new file mode 100644 index 000000000..9fd1d6ac7 --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package1.java @@ -0,0 +1,25 @@ +package abc; +import def.*; + +// This time, the around advice calls the private static method foo but the around advice +// will be inlined into a type in a different package (PrivateCall3). This should work +// as the around advice will call back to the aspect which will call on to foo(). + +public class PrivateCall_Instance_Package1 { + + public void test () {foo("test");} + + private void foo (String from) { + System.err.print(":"+from); + } + + public static void main(String[] args) { + new PrivateCall_Instance_Package1().test(); + } + + private static aspect Aspect { + pointcut execTest (PrivateCall_Instance_Package2 o) : execution(* PrivateCall_Instance_Package2.test()) && target(o); + before (PrivateCall_Instance_Package2 o) : execTest (o) { new PrivateCall_Instance_Package1().foo("before"); } + void around (PrivateCall_Instance_Package2 o) : execTest (o) { new PrivateCall_Instance_Package1().foo("around"); } + } +} \ No newline at end of file diff --git a/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package2.java b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package2.java new file mode 100644 index 000000000..38e20fc98 --- /dev/null +++ b/tests/bugs/doYouHaveVisiblePrivates/PrivateCall_Instance_Package2.java @@ -0,0 +1,11 @@ +package def; + +public class PrivateCall_Instance_Package2 { + public void test() { + + } + + public static void main(String []argv) { + new PrivateCall_Instance_Package2().test(); + } +} \ No newline at end of file