diff options
author | aclement <aclement> | 2006-05-17 09:43:15 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-17 09:43:15 +0000 |
commit | 4842f1826c3905c2789bc99a2dc841c733092339 (patch) | |
tree | e6ddf2c302b220133f961a76a21203117bdc0361 /tests | |
parent | 40c0d949493e14806799cb4975135998b707c9f2 (diff) | |
download | aspectj-4842f1826c3905c2789bc99a2dc841c733092339.tar.gz aspectj-4842f1826c3905c2789bc99a2dc841c733092339.zip |
testcode for 135865 and 142165
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bugs152/pr135865/A.java | 30 | ||||
-rw-r--r-- | tests/bugs152/pr135865/B.java | 6 | ||||
-rw-r--r-- | tests/bugs152/pr135865/One.java | 51 | ||||
-rw-r--r-- | tests/bugs152/pr142165/A.java | 6 | ||||
-rw-r--r-- | tests/bugs152/pr142165/C.java | 8 | ||||
-rw-r--r-- | tests/bugs152/pr142165/aop.xml | 11 | ||||
-rw-r--r-- | tests/bugs152/pr142165/aop2.xml | 11 | ||||
-rw-r--r-- | tests/bugs152/pr142165/aop3.xml | 11 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc152/ajc152.xml | 46 |
9 files changed, 180 insertions, 0 deletions
diff --git a/tests/bugs152/pr135865/A.java b/tests/bugs152/pr135865/A.java new file mode 100644 index 000000000..940540c26 --- /dev/null +++ b/tests/bugs152/pr135865/A.java @@ -0,0 +1,30 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) @interface Ann {} + + +aspect Aspect { + + // Call to an annotated method + pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b); + + // Top level call to an annotated method + pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann)); + + // Non top level call + pointcut annotatedNotTop(Ann b, Ann bTopo) : + annotated(b) && cflowbelow(annotatedTop(bTopo)); + + before(Ann b, Ann bTopo) : annotatedNotTop(b, bTopo) { + System.out.println("\tJoin point: " + thisJoinPointStaticPart); + } + + // Methods with out the Ann annotation but in an Ann annotated type get Ann + declare @method: !@Ann * (@Ann *).*(..) : @Ann; +} + +public class A { + @Ann void foo() { new B().foo(); new B().goo();} + public static void main(String[] args) { new A().foo(); } +} + diff --git a/tests/bugs152/pr135865/B.java b/tests/bugs152/pr135865/B.java new file mode 100644 index 000000000..c12542dd6 --- /dev/null +++ b/tests/bugs152/pr135865/B.java @@ -0,0 +1,6 @@ + +@Ann class B { + //@Ann + void foo() { } + void goo() { } +}
\ No newline at end of file diff --git a/tests/bugs152/pr135865/One.java b/tests/bugs152/pr135865/One.java new file mode 100644 index 000000000..f4110aa3b --- /dev/null +++ b/tests/bugs152/pr135865/One.java @@ -0,0 +1,51 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) @interface Ann {String value();} + +aspect Aspect { + + // Methods with out the Ann annotation but in an Ann annotated type get Ann +// declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced"); + + // Call to an annotated method + pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b); + + // Top level call to an annotated method + pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann)); + + // Non top level call + pointcut annotatedNotTop(Ann b, Ann bTopo) : + annotated(b) && cflowbelow(annotatedTop(bTopo)); + + before(Ann b, Ann bTopo) : + annotatedNotTop(b, bTopo) { + System.out.println("Non-top:"); + System.out.println("\tJoin point: " + thisJoinPointStaticPart); + System.out.println("\tEnclosing join point: " + thisEnclosingJoinPointStaticPart); + System.out.println("\tAnn: " + b); + System.out.println("\tTop annotation: " + bTopo); + } + +// before(Ann b) : +// annotatedTop(b) { +// System.out.println("Top:"); +// System.out.println("\tJoin point: " + thisJoinPointStaticPart); +// System.out.println("\tEnclosing join point: " + +//thisEnclosingJoinPointStaticPart); +// System.out.println("\tAnn: " + b); +// } +// declare @method: !@Ann * (@Ann *).*(..) : @Ann("introduced"); + declare @method: * B.goo() : @Ann("introduced"); +} + +public class A { + @Ann("A.foo") void foo() { new B().foo(); new B().goo();} + public static void main(String[] args) { new A().foo(); } +} + +@Ann("B") class B { + // The Ann is injected here! + @Ann("B.foo") + void foo() { } + void goo() { } +} diff --git a/tests/bugs152/pr142165/A.java b/tests/bugs152/pr142165/A.java new file mode 100644 index 000000000..a37879a7d --- /dev/null +++ b/tests/bugs152/pr142165/A.java @@ -0,0 +1,6 @@ +abstract aspect A { + abstract pointcut p(); + before(): p() { + System.err.println("advice"); + } +} diff --git a/tests/bugs152/pr142165/C.java b/tests/bugs152/pr142165/C.java new file mode 100644 index 000000000..e03fbc811 --- /dev/null +++ b/tests/bugs152/pr142165/C.java @@ -0,0 +1,8 @@ +public class C { + public static void main(String []argv) { + new C().foo(); + } + public void foo() {System.err.println("foo running");} +} + + diff --git a/tests/bugs152/pr142165/aop.xml b/tests/bugs152/pr142165/aop.xml new file mode 100644 index 000000000..5e89ba9d1 --- /dev/null +++ b/tests/bugs152/pr142165/aop.xml @@ -0,0 +1,11 @@ +<aspectj> + <weaver options="-Xnoinline"/> + <aspects> + <concrete-aspect name="AA" + extends="A"> + + <pointcut name="p" expression="within(SomeType) AND execution(* foo(..))" /> + + </concrete-aspect> + </aspects> +</aspectj> diff --git a/tests/bugs152/pr142165/aop2.xml b/tests/bugs152/pr142165/aop2.xml new file mode 100644 index 000000000..3fca4ec56 --- /dev/null +++ b/tests/bugs152/pr142165/aop2.xml @@ -0,0 +1,11 @@ +<aspectj> + <weaver options="-Xnoinline"/> + <aspects> + <concrete-aspect name="AA" + extends="A"> + + <pointcut name="p" expression="(within(*) AND (call(java.lang.String*.new(..)) || call(java.lang.Object.new(..))) )"/> + + </concrete-aspect> + </aspects> +</aspectj> diff --git a/tests/bugs152/pr142165/aop3.xml b/tests/bugs152/pr142165/aop3.xml new file mode 100644 index 000000000..d7ebd0732 --- /dev/null +++ b/tests/bugs152/pr142165/aop3.xml @@ -0,0 +1,11 @@ +<aspectj> + <weaver options="-Xnoinline"/> + <aspects> + <concrete-aspect name="AA" + extends="A"> + + <pointcut name="p" expression="within(C) AND call(* foo(..))" /> + + </concrete-aspect> + </aspects> +</aspectj> diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index 6378b42ca..eafefc2f0 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -15,6 +15,20 @@ </run> </ajc-test> + <ajc-test dir="bugs152/pr135865" title="misbehaving declare annotation"> + <compile files="B.java,A.java" options="-1.5"> + <!--message kind="weave" text="Join point 'method-call(void B.foo())' in Type 'A' (A.java:32) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/> + <message kind="weave" text="Join point 'method-call(void A.foo())' in Type 'A' (A.java:33) advised by before advice from 'Aspect' (A.java:22) [with runtime test]"/> + <message kind="weave" text="' void B.goo()' (A.java:7) is annotated with @Ann method annotation from 'Aspect' (A.java:27)"/--> + </compile> + <run class="A"> + <stdout> + <line text="Join point: call(void B.foo())"/> + <line text="Join point: call(void B.goo())"/> + </stdout> + </run> + </ajc-test> + <ajc-test dir="bugs152/pr129704" title="annotations and generics leading to BCException"> <compile files="A.java" options="-1.5"/> <run class="A"> @@ -309,4 +323,36 @@ </compile> </ajc-test> + <ajc-test dir="bugs152/pr142165" title="broken concretization"> + <compile files="C.java" options="-1.5"/> + <compile files="A.java" options="-1.5"/> + <run class="C" ltw="aop.xml"> + <stderr> + <line text="warning at Type 'AA' (no debug info available)::0 no match for this type name: SomeType [Xlint:invalidAbsoluteTypeName]"/> + <line text="foo running"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="bugs152/pr142165" title="broken concretization - 2"> + <compile files="C.java" options="-1.5"/> + <compile files="A.java" options="-1.5"/> + <run class="C" ltw="aop2.xml"> + <stderr> + <line text="foo running"/> + </stderr> + </run> + </ajc-test> + + <ajc-test dir="bugs152/pr142165" title="broken concretization - 3"> + <compile files="C.java" options="-1.5"/> + <compile files="A.java" options="-1.5"/> + <run class="C" ltw="aop3.xml"> + <stderr> + <line text="advice"/> + <line text="foo running"/> + </stderr> + </run> + </ajc-test> + </suite>
\ No newline at end of file |