aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/generics
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-10-05 14:35:24 +0000
committeracolyer <acolyer>2005-10-05 14:35:24 +0000
commitaced19f8d64774cb18d33bc2252511f5a02ce53f (patch)
tree54cd21ab00d9dab97a5aeed5bf7f826737b64c0f /tests/java5/generics
parent727b0f5356e50761530655b52cbc0a96aff75c05 (diff)
downloadaspectj-aced19f8d64774cb18d33bc2252511f5a02ce53f.tar.gz
aspectj-aced19f8d64774cb18d33bc2252511f5a02ce53f.zip
some abstract generic aspect tests, not yet linked into main suite
Diffstat (limited to 'tests/java5/generics')
-rw-r--r--tests/java5/generics/genericaspects/GenericAspectPointcuts.aj72
-rw-r--r--tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj99
-rw-r--r--tests/java5/generics/genericaspects/testplan.txt74
3 files changed, 245 insertions, 0 deletions
diff --git a/tests/java5/generics/genericaspects/GenericAspectPointcuts.aj b/tests/java5/generics/genericaspects/GenericAspectPointcuts.aj
new file mode 100644
index 000000000..0ca1bbc20
--- /dev/null
+++ b/tests/java5/generics/genericaspects/GenericAspectPointcuts.aj
@@ -0,0 +1,72 @@
+abstract aspect GenericAspectPointcuts<S,T,E> {
+
+ /**
+ test declare warning with :
+ - KindedPointcut
+ all parts of Signature pattern
+ - HandlerPointcut
+ - ReferencePointcut
+ - WithincodePointcut
+ - WithinPointcut
+ - And
+ - Or
+ - Not
+ */
+
+ pointcut kindedWithReturning() : execution(T *(..));
+ pointcut kindedWithDeclaring() : call(* S.*(..));
+ pointcut kindedWithParams() : execution(* *(T));
+ pointcut kindedWithThrows() : execution(* *(..) throws E);
+
+ pointcut p1() : execution(* T.*(..));
+ pointcut p2() : execution(S *(..));
+ pointcut p3() : set(S a);
+ pointcut p4() : get(* T.*);
+ pointcut p5() : within(S || T);
+
+ pointcut handlerPC() : handler(E);
+
+ declare warning : kindedWithReturning() : "kinded-returning-ok";
+ declare warning : kindedWithDeclaring() : "kinded-declaring-ok";
+ declare warning : kindedWithParams() : "kinded-params-ok";
+ declare warning : kindedWithThrows() : "kinded-throws-ok";
+
+ declare warning : p1() && p2() : "and-ok";
+ declare warning : p3() || p4() : "or-ok";
+ declare warning : staticinitialization(*) && !p5() : "not-ok";
+
+ declare warning : within(T) && staticinitialization(*) : "within-ok";
+ declare warning : withincode(S T.*(..)) : "withincode-ok";
+}
+
+aspect Sub extends GenericAspectPointcuts<A,B,Z> {
+
+ declare warning : handlerPC() : "handler-ok"; // also tests ref to super pointcut
+}
+
+
+
+class A {
+ void bar(B b) {
+ try {
+ t();
+ } catch( Z z) { System.out.println("z");}
+ }
+
+ void t() throws Z {}
+}
+
+class B {
+ A a = new A();
+
+ B newB() { return new B(); }
+
+ A newA() { return a; }
+
+ void foo() {
+ a.bar(this);
+ }
+
+}
+
+class Z extends Exception {} \ No newline at end of file
diff --git a/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj b/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj
new file mode 100644
index 000000000..8436e719f
--- /dev/null
+++ b/tests/java5/generics/genericaspects/GenericAspectRuntimePointcuts.aj
@@ -0,0 +1,99 @@
+import java.lang.annotation.*;
+
+abstract aspect GA<P,Q,A extends Annotation> {
+
+ /*
+ * test before advice with
+ - CflowPointcut
+ - annotation
+ - args annotation
+ - args
+ - this
+ - target
+ - @this
+ - @target
+ - @within
+ - @withincode
+ - parameter binding
+ */
+
+ before(P p, Q q) : cflow(execution(* P.*(..)) && this(p)) && set(Q q) {
+ System.out.println("cflow-ok " + p + " " + q);
+ }
+
+ before(A a) : execution(* *(..)) && @annotation(a) {
+ System.out.println("@annotation-ok " + a);
+ }
+
+ before(A a) : @args(a) {
+ System.out.println("@args-ok " + a);
+ }
+
+ before(P p) : args(..,p) {
+ System.out.println("args-ok " + p);
+ }
+
+ before(Q q) : this(q) && execution(* *(..)) {
+ System.out.println("this-ok " + q);
+ }
+
+ before(P p) : target(p) && call(* *(..)) {
+ System.out.println("target-ok " + p);
+ }
+
+ before(A a) : @this(a) && execution(* *(..)) {
+ System.out.println("@this-ok " + a);
+ }
+
+ before(A a) : @target(a) && call(* *(..)) {
+ System.out.println("@target-ok " + a);
+ }
+
+ before(A a) : @within(a) && execution(* *(..)) {
+ System.out.println("@within-ok " + a);
+ }
+
+ before(A a) : @withincode(a) && get(* *) {
+ System.out.println("@withincode-ok " + a);
+ }
+}
+
+aspect GenericAspectRuntimePointcuts extends GA<X,Y,MyAnnotation> {
+
+ public static void main(String[] s) {
+ X x = new X();
+ Y y = new Y();
+ x.foo();
+ x.bar();
+ y.foo(x);
+ y.bar();
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface MyAnnotation {
+ String value() default "my-value";
+}
+
+@MyAnnotation
+class X {
+ Y y;
+
+ void foo() {
+ this.y = new Y();
+ }
+
+ @MyAnnotation("bar")
+ void bar() {}
+
+}
+
+@MyAnnotation("on Y")
+class Y {
+ X x;
+
+ void foo(X x) {}
+
+ @MyAnnotation
+ X bar() { return this.x; }
+} \ No newline at end of file
diff --git a/tests/java5/generics/genericaspects/testplan.txt b/tests/java5/generics/genericaspects/testplan.txt
new file mode 100644
index 000000000..2d4c2a944
--- /dev/null
+++ b/tests/java5/generics/genericaspects/testplan.txt
@@ -0,0 +1,74 @@
+Test plan for abstract aspects:
+
+Coverage:
+ * all pointcut types
+ * all declare types
+ * all annotation pattern nodes
+ * all type pattern nodes
+ * type variables as type parameters
+
+ * Binary weaving!!!
+
+Pointcut types:
+
+ * test declare warning with : DONE
+ - KindedPointcut
+ all parts of Signature pattern
+ - HandlerPointcut
+ - ReferencePointcut
+ - WithincodePointcut
+ - WithinPointcut
+ - And
+ - Or
+ - Not
+
+ * test before advice with
+ - CflowPointcut
+ - annotation
+ - args annotation
+ - args
+ - this
+ - target
+ - @this
+ - @target
+ - @within
+ - @withincode
+ - parameter binding
+
+ * pointcut in abstract class
+ - 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
+
+AnnotationPatternNodes:
+
+ * And
+ * Or
+ * Not
+ * Exact
+ * Wild
+
+Type pattern Nodes:
+
+ * And
+ * AnyWithAnnotation
+ * Or
+ * Not
+ * HasMember
+ * Exact
+ * Wild
+ * type variables as type parameters
+
+Multi-level hierarchy:
+
+ * test 3-deep with partial parameterization in middle
+
+ \ No newline at end of file