diff options
author | acolyer <acolyer> | 2005-10-06 22:11:23 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-10-06 22:11:23 +0000 |
commit | d8db661b5d5804a7d544cca2096c4cfce641a154 (patch) | |
tree | 2c97d1541138fee1e6f76758982112391623cad5 /tests/java5 | |
parent | 75f50930796059524f6e3435037fd3bea69503d4 (diff) | |
download | aspectj-d8db661b5d5804a7d544cca2096c4cfce641a154.tar.gz aspectj-d8db661b5d5804a7d544cca2096c4cfce641a154.zip |
tests for generic abstract aspects
Diffstat (limited to 'tests/java5')
8 files changed, 188 insertions, 30 deletions
diff --git a/tests/java5/generics/genericaspects/DecAnnGenericTest.aj b/tests/java5/generics/genericaspects/DecAnnGenericTest.aj new file mode 100644 index 000000000..c42160f21 --- /dev/null +++ b/tests/java5/generics/genericaspects/DecAnnGenericTest.aj @@ -0,0 +1,35 @@ +import java.lang.annotation.*; + + +abstract aspect DAGenTest<X> { + + declare @type: X : @MyAnnotation; + + declare @method: * X.*(..) : @MyAnnotation; + + declare @constructor: X.new(..) : @MyAnnotation; + + declare @field: X X.* : @MyAnnotation; + +} + +@interface MyAnnotation {} + +class C { + + C c = null; + + public C() {} + + public void foo() {} + +} + +aspect Sub extends DAGenTest<C> { + + declare warning : staticinitialization(@MyAnnotation *) : "@type ok"; + declare warning : execution(@MyAnnotation *.new(..)) : "@constructor ok"; + declare warning : execution(@MyAnnotation * *.*(..)) : "@method ok"; + declare warning : set(@MyAnnotation * *) : "@field ok"; + +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/DecPGenericTest.aj b/tests/java5/generics/genericaspects/DecPGenericTest.aj new file mode 100644 index 000000000..0634679ab --- /dev/null +++ b/tests/java5/generics/genericaspects/DecPGenericTest.aj @@ -0,0 +1,21 @@ + +abstract aspect DecPGenericTest<X,Y> { + + declare parents : X implements Y; + +} + +aspect Sub extends DecPGenericTest<C,I> { + + declare warning : execution(* I+.foo()) : "success"; + +} + +class C { + + void foo() {} + +} + +interface I {} + diff --git a/tests/java5/generics/genericaspects/DecPrecedenceGenericTest.aj b/tests/java5/generics/genericaspects/DecPrecedenceGenericTest.aj new file mode 100644 index 000000000..7b95f079a --- /dev/null +++ b/tests/java5/generics/genericaspects/DecPrecedenceGenericTest.aj @@ -0,0 +1,34 @@ +abstract aspect DecPrecedenceSuper<X,Y> { + + declare precedence: X,Y; + +} + +aspect Sub extends DecPrecedenceSuper<A1,A2> {} + +public class DecPrecedenceGenericTest { + + public static void main(String[] args) { + new C().foo(); + } +} + + +aspect A2 { + + before() : execution(* C.*(..)) { System.out.println("A2"); } + +} + + +aspect A1 { + + before() : execution(* C.*(..)) { System.out.println("A1"); } + +} + +class C { + + void foo() {} + +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj b/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj index a1481f92c..7615d728e 100644 --- a/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj +++ b/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj @@ -18,48 +18,54 @@ abstract aspect GA<P,Q,A extends Annotation> { */ before(P p, Q q) : cflow(execution(* P.*(..)) && this(p)) && set(Q *) && args(q) { - System.out.println("cflow-ok " + p + " " + q); + System.out.println("cflow-ok " + p + " " + q + " " + thisJoinPoint); } - before(A a) : execution(* *(..)) && @annotation(a) { - System.out.println("@annotation-ok " + a); + before(A a) : execution(* *(..)) && @annotation(a) && !execution(* toString()){ + System.out.println("@annotation-ok " + a + " " + thisJoinPoint); } - before(A a) : @args(a) { - System.out.println("@args-ok " + a); + before(A a) : execution(* *(..)) && @args(a) && !execution(* toString()){ + System.out.println("@args-ok " + a + " " + thisJoinPoint); } - before(P p) : args(..,p) { - System.out.println("args-ok " + p); + before(P p) : execution(* *(..)) && args(..,p) && !execution(* toString()){ + System.out.println("args-ok " + p + " " + thisJoinPoint); } - before(Q q) : this(q) && execution(* *(..)) { - System.out.println("this-ok " + q); + before(Q q) : this(q) && execution(* *(..)) && !execution(* toString()){ + System.out.println("this-ok " + q + " " + thisJoinPoint); } - before(P p) : target(p) && call(* *(..)) { - System.out.println("target-ok " + p); + before(P p) : target(p) && execution(* *(..)) && !execution(* toString()){ + System.out.println("target-ok " + p + " " + thisJoinPoint); } - before(A a) : @this(a) && execution(* *(..)) { - System.out.println("@this-ok " + a); + before(A a) : @this(a) && execution(* *(..)) && !execution(* toString()){ + System.out.println("@this-ok " + a + " " + thisJoinPoint); } - before(A a) : @target(a) && call(* *(..)) { - System.out.println("@target-ok " + a); + before(A a) : @target(a) && execution(* *(..)) && !execution(* toString()){ + System.out.println("@target-ok " + a + " " + thisJoinPoint); } - before(A a) : @within(a) && execution(* *(..)) { - System.out.println("@within-ok " + a); + before(A a) : @within(a) && execution(* *(..)) && !execution(* toString()){ + System.out.println("@within-ok " + a + " " + thisJoinPoint); } before(A a) : @withincode(a) && get(* *) { - System.out.println("@withincode-ok " + a); + System.out.println("@withincode-ok " + a + " " + thisJoinPoint); } } -aspect GenericAspectRuntimePointcuts extends GA<X,Y,MyAnnotation> { - +aspect Sub extends GA<X,Y,MyAnnotation> { + + before(MyAnnotation a) : execution(* bar(..)) && @annotation(a) && !execution(* toString()){ + System.out.println("@annotation-ok-sub " + a + " " + thisJoinPoint); + } +} + +public class GenericAspectRuntimePointcuts { public static void main(String[] s) { X x = new X(); Y y = new Y(); @@ -86,6 +92,7 @@ class X { @MyAnnotation("bar") void bar() {} + public String toString() { return "an X"; } } @MyAnnotation("on Y") @@ -96,4 +103,6 @@ class Y { @MyAnnotation X bar() { return this.x; } + + public String toString() { return "a Y"; } }
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/MultiLevelGenericTest.aj b/tests/java5/generics/genericaspects/MultiLevelGenericTest.aj new file mode 100644 index 000000000..9a43ccae8 --- /dev/null +++ b/tests/java5/generics/genericaspects/MultiLevelGenericTest.aj @@ -0,0 +1,25 @@ +abstract aspect Base<S,T> { + + declare warning : execution(S T.*(..)) : "base match"; + +} + +abstract aspect Middle<X> extends Base<C,X> { + + declare warning : execution(C X.*(..)) : "middle match"; + +} + +aspect Top extends Middle<B> { + + declare warning : execution(C B.*(..)) : "top match"; + +} + +class C {} + +class B { + + C getC() { return null; } + +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/PointcutsInGenericClasses.aj b/tests/java5/generics/genericaspects/PointcutsInGenericClasses.aj new file mode 100644 index 000000000..3495fc2e3 --- /dev/null +++ b/tests/java5/generics/genericaspects/PointcutsInGenericClasses.aj @@ -0,0 +1,17 @@ +public class PointcutsInGenericClasses<T> { + + pointcut foo() : execution(* T.*(..)); + + +} + +aspect X { + + declare warning : PointcutsInGenericClasses<C>.foo() : "a match"; + + +} + +class C { + void bar() {} +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/PointcutsInGenericClasses2.aj b/tests/java5/generics/genericaspects/PointcutsInGenericClasses2.aj new file mode 100644 index 000000000..6c96371e9 --- /dev/null +++ b/tests/java5/generics/genericaspects/PointcutsInGenericClasses2.aj @@ -0,0 +1,17 @@ +public class PointcutsInGenericClasses2<T> { + + pointcut foo() : execution(* T.*(..)); + + +} + +aspect X { + + declare warning : PointcutsInGenericClasses2.foo() : "a match"; + + +} + +class C { + void bar() {} +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/testplan.txt b/tests/java5/generics/genericaspects/testplan.txt index 2d4c2a944..2a191a03f 100644 --- a/tests/java5/generics/genericaspects/testplan.txt +++ b/tests/java5/generics/genericaspects/testplan.txt @@ -22,7 +22,7 @@ Pointcut types: - Or - Not - * test before advice with + * test before advice with DONE - CflowPointcut - annotation - args annotation @@ -35,18 +35,18 @@ Pointcut types: - @withincode - parameter binding - * pointcut in abstract class + * pointcut in generic class DONE - ref with parameterized type - ref without parameterized type (error) Declares: - * declare warning / error (covered above) - * declare parents - * declare soft - * declare precedence - * declare @type - * declare @field / method / cons + * declare warning / error (covered above) DONE + * declare parents DONE + * declare soft DONE + * declare precedence DONE + * declare @type DONE + * declare @field / method / cons DONE AnnotationPatternNodes: @@ -65,9 +65,9 @@ Type pattern Nodes: * HasMember * Exact * Wild - * type variables as type parameters + * type variables as type parameters DONE -Multi-level hierarchy: +Multi-level hierarchy: DONE * test 3-deep with partial parameterization in middle |