diff options
author | acolyer <acolyer> | 2005-08-11 15:30:37 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-08-11 15:30:37 +0000 |
commit | 43cf534bfd8f852d85b42b5dd0d7d5fbe2956e69 (patch) | |
tree | a933660fa90ec7a9319476c267b1060fd6c30f4a | |
parent | da1791018ec0ac7abebb809f901b7f06399b6047 (diff) | |
download | aspectj-43cf534bfd8f852d85b42b5dd0d7d5fbe2956e69.tar.gz aspectj-43cf534bfd8f852d85b42b5dd0d7d5fbe2956e69.zip |
generic aspect testcases - woohoo!
4 files changed, 118 insertions, 0 deletions
diff --git a/tests/java5/generics/genericaspects/AnonymousPointcutInGenericAspect.aj b/tests/java5/generics/genericaspects/AnonymousPointcutInGenericAspect.aj new file mode 100644 index 000000000..d8dabf7fb --- /dev/null +++ b/tests/java5/generics/genericaspects/AnonymousPointcutInGenericAspect.aj @@ -0,0 +1,28 @@ +abstract aspect SuperAspect<T> { + + before() : execution(* *(T)) { + System.out.println("I matched at " + thisJoinPointStaticPart); + } + +} + +public aspect AnonymousPointcutInGenericAspect extends SuperAspect<String> { + + public static void main(String[] args) { + C c = new C(); + c.foo("well i never"); + c.bar(5); + } + +} + +class C { + + // should be matched + public void foo(String s) {} + + // should not be matched + public void bar(Number n) {} + + +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/DeclareParentsWithTypeVars.aj b/tests/java5/generics/genericaspects/DeclareParentsWithTypeVars.aj new file mode 100644 index 000000000..48b729bf9 --- /dev/null +++ b/tests/java5/generics/genericaspects/DeclareParentsWithTypeVars.aj @@ -0,0 +1,37 @@ +import java.lang.reflect.*; + +abstract aspect GiveMeFoo<T> { + + declare parents : C implements I<T>; + +} + +public aspect DeclareParentsWithTypeVars extends GiveMeFoo<String> { + + public static void main(String[] args) { + C c = new C(); + if (! (c instanceof I)) throw new RuntimeException("C should implement I"); + Type[] superinterfaces = C.class.getGenericInterfaces(); + if (! (superinterfaces[0] instanceof ParameterizedType)) throw new RuntimeException("Expected to get parameterized interface but found " + superinterfaces[0]); + ParameterizedType pt = (ParameterizedType) superinterfaces[0]; + Type[] typeArguments = pt.getActualTypeArguments(); + if (typeArguments[0] != String.class) throw new RuntimeException("Expecting String parameter but found " + typeArguments[0]); + } + +} + +class C { + +// public Object identity(Object o) { return o; } + + public String identity(String aString) { + return aString; + } + +} + +interface I<E> { + + E identity(E anE); + +} diff --git a/tests/java5/generics/genericaspects/DeclareWarningInGenericAspect.aj b/tests/java5/generics/genericaspects/DeclareWarningInGenericAspect.aj new file mode 100644 index 000000000..b0cc510b4 --- /dev/null +++ b/tests/java5/generics/genericaspects/DeclareWarningInGenericAspect.aj @@ -0,0 +1,22 @@ +abstract aspect SuperAspect<T> { + + pointcut takesAT() : execution(* *(T)); + + declare warning : takesAT() : "this method takes a T!"; +} + + +public aspect DeclareWarningInGenericAspect extends SuperAspect<String> { + +} + +class C { + + // should be matched + public void foo(String s) {} + + // should not be matched + public void bar(Number n) {} + + +}
\ No newline at end of file diff --git a/tests/java5/generics/genericaspects/ExecutionAdviceInGenericAspect.aj b/tests/java5/generics/genericaspects/ExecutionAdviceInGenericAspect.aj new file mode 100644 index 000000000..27624bc63 --- /dev/null +++ b/tests/java5/generics/genericaspects/ExecutionAdviceInGenericAspect.aj @@ -0,0 +1,31 @@ +abstract aspect SuperAspect<T> { + + pointcut takesAT() : execution(* *(T)); + + before() : takesAT() { + System.out.println("I matched at " + thisJoinPointStaticPart); + } + +} + + +public aspect ExecutionAdviceInGenericAspect extends SuperAspect<String> { + + public static void main(String[] args) { + C c = new C(); + c.foo("well i never"); + c.bar(5); + } + +} + +class C { + + // should be matched + public void foo(String s) {} + + // should not be matched + public void bar(Number n) {} + + +}
\ No newline at end of file |