aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/generics/pointcuts
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-08-04 13:19:47 +0000
committeracolyer <acolyer>2005-08-04 13:19:47 +0000
commit7b2bd108b72dbe26c15be6e976fc499e0d8759fc (patch)
tree777c08df5b238b403e1ec7fe21de85a9633aaad3 /tests/java5/generics/pointcuts
parent7c1a5d72a8549771b076af20b4caff8e1da903bd (diff)
downloadaspectj-7b2bd108b72dbe26c15be6e976fc499e0d8759fc.tar.gz
aspectj-7b2bd108b72dbe26c15be6e976fc499e0d8759fc.zip
improved and additional signature matching tests
Diffstat (limited to 'tests/java5/generics/pointcuts')
-rw-r--r--tests/java5/generics/pointcuts/WithinCodeOverriding.aj68
-rw-r--r--tests/java5/generics/pointcuts/WithinCodePointcutMatchingParamAndReturnTypes.aj64
-rw-r--r--tests/java5/generics/pointcuts/WithincodePointcutMatching.aj18
3 files changed, 150 insertions, 0 deletions
diff --git a/tests/java5/generics/pointcuts/WithinCodeOverriding.aj b/tests/java5/generics/pointcuts/WithinCodeOverriding.aj
new file mode 100644
index 000000000..ba7160968
--- /dev/null
+++ b/tests/java5/generics/pointcuts/WithinCodeOverriding.aj
@@ -0,0 +1,68 @@
+public aspect WithinCodeOverriding {
+
+ // if a type overrides a generic method from a supertype, changing the
+ // signature in the process (for example, is a generic subtype with a
+ // narrowed type variable, or extends a parameterized super class, or
+ // implements a parameterized interface), then a type pattern of
+ // OriginalDeclaringType.erasureOfOriginalSignature matches, and a
+ // type pattern of *.erasureOfOriginalSignature matches, but
+ // a type pattern OverridingType.erasureOfOriginalSignature DOES NOT
+ // MATCH.
+
+ declare warning : withincode(void *.foo(Object))
+ : "wildcard declaring type match on erasure";
+}
+
+class Generic<T> {
+ int x = 0;
+
+ // withincode (void Generic.foo(Object))
+ // withincode (void *.foo(Object))
+ public void foo(T someObject) {
+ x = 1;
+ }
+
+}
+
+class SubGeneric<N extends Number> extends Generic<N> {
+ int y = 0;
+
+ // withincode(void Generic.foo(Object))
+ // withincode( void *.foo(Object))
+ // withincode(void SubGeneric.foo(Number))
+ // !withincode(void SubGeneric.foo(Object))
+ public void foo(N someObject) {
+ y = 1;
+ }
+
+}
+
+class SubParameterized extends Generic<String> {
+ int y = 0;
+
+ // withincode(void Generic.foo(Object))
+ // withincode( void *.foo(Object))
+ // withincode(void SubParameterized.foo(String))
+ // !withincode(void SubGeneric.foo(Object))
+ public void foo(String someObject) {
+ y = 1;
+ }
+
+}
+
+interface I<E> {
+ void bar(E anElement);
+}
+
+class ParameterizedI implements I<Double> {
+ int x;
+
+ // withincode(void I.bar(Object))
+ // withincode(void *.bar(Object))
+ // withincode(void ParameterizedI.bar(Double))
+ // !withincode(void ParameterizedI.bar(Object))
+ public void bar(Double d) {
+ x = 1;
+ }
+}
+
diff --git a/tests/java5/generics/pointcuts/WithinCodePointcutMatchingParamAndReturnTypes.aj b/tests/java5/generics/pointcuts/WithinCodePointcutMatchingParamAndReturnTypes.aj
new file mode 100644
index 000000000..a57e9f75d
--- /dev/null
+++ b/tests/java5/generics/pointcuts/WithinCodePointcutMatchingParamAndReturnTypes.aj
@@ -0,0 +1,64 @@
+import java.util.*;
+
+public aspect WithinCodePointcutMatchingParamAndReturnTypes {
+
+ // rule 3) a raw parameter pattern matches any parameterized type
+ declare warning : withincode(Generic.new(List))
+ : "raw param type matching in withincode ok";
+ declare warning : withincode(List UglyBuilding.foo())
+ : "raw return type matching in withincode ok";
+
+ // rule 4) A param type declared using a type variable is matched by its erasure
+ declare warning : withincode(Generic.new(Object))
+ : "erasure type matching in withincode ok";
+ declare warning : withincode(Object Generic.foo())
+ : "erasure type matching in withincode ok";
+
+ // rule 5) no join points in bridge methods
+ declare warning : withincode(void UglyBuilding.iSee(String))
+ : "withincode and parameterized method ok";
+ declare warning : withincode(* ISore.*(..))
+ : "withincode and generic interface ok";
+ declare warning : withincode(* I2.*(..))
+ : "withincode and interface control test";
+ declare warning : withincode(void UglyBuilding.iSee(Object))
+ : "should be no join points for bridge methods";
+}
+
+
+class Generic<T> {
+ int x;
+ public Generic(List<String> ls) {
+ x = 5;
+ }
+ public Generic(T t) {
+ x = 6;
+ }
+
+ T foo() { x = 7; return null; }
+}
+
+interface ISore<E> {
+
+ void iSee(E anE);
+
+}
+
+interface I2 {
+ void ic2it();
+}
+
+class UglyBuilding implements ISore<String>, I2 {
+
+ int y;
+
+ // this class will have a bridge method with signature void iSee(Object), with a cast and call
+ // to the method below
+ public void iSee(String s) {
+ y = 2;
+ }
+
+ public void ic2it() { y = 4; }
+
+ List<Number> foo() { y = 1; return null; }
+} \ No newline at end of file
diff --git a/tests/java5/generics/pointcuts/WithincodePointcutMatching.aj b/tests/java5/generics/pointcuts/WithincodePointcutMatching.aj
new file mode 100644
index 000000000..a1730c126
--- /dev/null
+++ b/tests/java5/generics/pointcuts/WithincodePointcutMatching.aj
@@ -0,0 +1,18 @@
+public aspect WithincodePointcutMatching {
+
+ // rule 1) you can't use generic or parameterized type patterns in the declaring type position
+ pointcut tryWcGeneric() : withincode(* Generic<T>.*(..)); // CE L 4
+ pointcut tryWcParameterized() : withincode(* Generic<String>.*(..)); // CE L5
+ pointcut badThrows() : withincode(* Generic.*(..) throws Ex*<String>); // CE L6
+}
+
+
+class Generic<T> {
+
+ T foo = null;
+
+ T getFoo() {
+ return foo;
+ }
+
+}