From ceb8d527356c158d321f49efb0ca53dc12762150 Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 13 Jul 2005 12:59:45 +0000 Subject: more test cases covering generics in pointcut expressions --- .../generics/pointcuts/GenericSignatureMatching.aj | 17 +++++++++++++ .../generics/pointcuts/HandlerPointcutTests.aj | 13 ++++++++++ .../ParameterizedTypesInAnnotationPatterns.aj | 14 +++++++++++ .../pointcuts/ParameterizedTypesInAtPCDs.aj | 15 ++++++++++++ .../pointcuts/PointcutsThatDontAllowTypeVars.aj | 28 ++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 tests/java5/generics/pointcuts/GenericSignatureMatching.aj create mode 100644 tests/java5/generics/pointcuts/HandlerPointcutTests.aj create mode 100644 tests/java5/generics/pointcuts/ParameterizedTypesInAnnotationPatterns.aj create mode 100644 tests/java5/generics/pointcuts/ParameterizedTypesInAtPCDs.aj create mode 100644 tests/java5/generics/pointcuts/PointcutsThatDontAllowTypeVars.aj (limited to 'tests/java5/generics') diff --git a/tests/java5/generics/pointcuts/GenericSignatureMatching.aj b/tests/java5/generics/pointcuts/GenericSignatureMatching.aj new file mode 100644 index 000000000..28faf00eb --- /dev/null +++ b/tests/java5/generics/pointcuts/GenericSignatureMatching.aj @@ -0,0 +1,17 @@ +public aspect GenericSignatureMatching { + + // tests that references to a generic or parameterized type are + // always matched by a type pattern refering to the raw type form + + void someCode() { + ConcreteImplementingClass cic = new ConcreteImplementingClass(); + cic.asInt(5.0d); + GenericImplementingClass gic = new GenericImplementingClass(); + gic.asInt(55L); + } + + declare warning : + execution(* GenericInterface.asInt(T)) : + "execution(* GenericInterface.asInt(T))"; + +} \ No newline at end of file diff --git a/tests/java5/generics/pointcuts/HandlerPointcutTests.aj b/tests/java5/generics/pointcuts/HandlerPointcutTests.aj new file mode 100644 index 000000000..8324d198d --- /dev/null +++ b/tests/java5/generics/pointcuts/HandlerPointcutTests.aj @@ -0,0 +1,13 @@ +public aspect HandlerPointcutTests { + + // CE line 4 - no type variables allowed in handler + pointcut exceptionHandler() : handler(GenericInterface); + + // CE line 8 - no parameterized types + // CW line 8 - unresolved absolute type name T + pointcut unboundTypeInHandler() : handler(GenericInterface); + + // CE line 11 - no parameterized types + pointcut parameterizedHandler() : handler(GenericInterface); + +} \ No newline at end of file diff --git a/tests/java5/generics/pointcuts/ParameterizedTypesInAnnotationPatterns.aj b/tests/java5/generics/pointcuts/ParameterizedTypesInAnnotationPatterns.aj new file mode 100644 index 000000000..54b538491 --- /dev/null +++ b/tests/java5/generics/pointcuts/ParameterizedTypesInAnnotationPatterns.aj @@ -0,0 +1,14 @@ +import java.util.List; + +public aspect ParameterizedTypesInAnnotationPatterns { + // CE - not an annotation type + pointcut simple() : staticinitialization(@List String); + // CE - not an annotation type + pointcut generic() : staticinitialization(@List Class); + + // no CE, good enough for now? may improve error reporting for this later + pointcut combined() : staticinitialization(@(Foo || List) String); + +} + +@interface Foo {} \ No newline at end of file diff --git a/tests/java5/generics/pointcuts/ParameterizedTypesInAtPCDs.aj b/tests/java5/generics/pointcuts/ParameterizedTypesInAtPCDs.aj new file mode 100644 index 000000000..d92cc7c73 --- /dev/null +++ b/tests/java5/generics/pointcuts/ParameterizedTypesInAtPCDs.aj @@ -0,0 +1,15 @@ +public aspect ParameterizedTypesInAtPCDs { + + public pointcut atthis() : @this(List); + + public pointcut attarget() : @target(List); + + public pointcut atargs() : @args(List); + + public pointcut atannotation() : @annotation(List); + + public pointcut atwithin() : @within(List); + + public pointcut atwithincode() : @withincode(List); + +} \ No newline at end of file diff --git a/tests/java5/generics/pointcuts/PointcutsThatDontAllowTypeVars.aj b/tests/java5/generics/pointcuts/PointcutsThatDontAllowTypeVars.aj new file mode 100644 index 000000000..15b622e49 --- /dev/null +++ b/tests/java5/generics/pointcuts/PointcutsThatDontAllowTypeVars.aj @@ -0,0 +1,28 @@ +public aspect PointcutsThatDontAllowTypeVars { + + public pointcut handlerWithVars() : handler(*); + + public pointcut cflowWithVars() : cflow(ifWithVars()); + + public pointcut cflowbelowWithVars() : cflowbelow(ifWithVars()); + + public pointcut thisWithVars() : this(String); + + public pointcut targetWithVars() : target(String); + + public pointcut argsWithVars() : args(String); + + public pointcut atthisWithVars() : @this(*); + + public pointcut attargetWithVars() : @target(*); + + public pointcut atargsWithVars() : @args(*); + + public pointcut atwithinWithVars() : @within(*); + + public pointcut atwithincodeWithVars() : @withincode(*); + + public pointcut atannotationWithVars() : @annotation(*); + + public pointcut ifWithVars() : if(true); // message for this one should be improved... +} \ No newline at end of file -- cgit v1.2.3