diff options
author | aclement <aclement> | 2005-06-02 11:09:21 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-06-02 11:09:21 +0000 |
commit | 8459fa6a55bb37e629b1c4e7b610f016f499f51a (patch) | |
tree | 9d8e601fea4d23f08411f67762e92a84ad041378 /tests/java5/generics | |
parent | 19890f1a69e97fd5defa731b596e70f65eaf441e (diff) | |
download | aspectj-8459fa6a55bb37e629b1c4e7b610f016f499f51a.tar.gz aspectj-8459fa6a55bb37e629b1c4e7b610f016f499f51a.zip |
GenericsWork: ITD testcode
Diffstat (limited to 'tests/java5/generics')
-rw-r--r-- | tests/java5/generics/bugs/PR95992.java | 8 | ||||
-rw-r--r-- | tests/java5/generics/decp/Basic.aj | 13 | ||||
-rw-r--r-- | tests/java5/generics/decp/Basic2.aj | 12 | ||||
-rw-r--r-- | tests/java5/generics/itds/A.java | 21 | ||||
-rw-r--r-- | tests/java5/generics/itds/B.java | 21 | ||||
-rw-r--r-- | tests/java5/generics/itds/C.java | 8 | ||||
-rw-r--r-- | tests/java5/generics/itds/D.java | 11 | ||||
-rw-r--r-- | tests/java5/generics/itds/Parse1.java | 6 | ||||
-rw-r--r-- | tests/java5/generics/itds/Parse2.java | 6 | ||||
-rw-r--r-- | tests/java5/generics/itds/Parse3.java | 6 | ||||
-rw-r--r-- | tests/java5/generics/itds/Parse4.java | 8 | ||||
-rw-r--r-- | tests/java5/generics/itds/Parse5.java | 16 |
12 files changed, 136 insertions, 0 deletions
diff --git a/tests/java5/generics/bugs/PR95992.java b/tests/java5/generics/bugs/PR95992.java new file mode 100644 index 000000000..824967fe9 --- /dev/null +++ b/tests/java5/generics/bugs/PR95992.java @@ -0,0 +1,8 @@ +interface Base<T> { + static interface Inner { + } +} +class Test<T extends Test.InnerTest> implements Base<T> { + static class InnerTest implements Inner { + } +} diff --git a/tests/java5/generics/decp/Basic.aj b/tests/java5/generics/decp/Basic.aj new file mode 100644 index 000000000..dee3872e6 --- /dev/null +++ b/tests/java5/generics/decp/Basic.aj @@ -0,0 +1,13 @@ +interface I<T>{ } + +public class Basic{ + + public static void main(String[]argv) { + Basic b = new Basic(); + if (b instanceof I) throw new RuntimeException("Should implement I??"); + } +} + +aspect X{ + declare parents: Basic implements I<String>; +} diff --git a/tests/java5/generics/decp/Basic2.aj b/tests/java5/generics/decp/Basic2.aj new file mode 100644 index 000000000..d1127d1ed --- /dev/null +++ b/tests/java5/generics/decp/Basic2.aj @@ -0,0 +1,12 @@ +// error, can't implement two variants of a generic type +interface I<T>{ } + +public class Basic implements I<String> { + + public static void main(String[]argv) { + } +} + +aspect X{ + declare parents: Basic implements I<Integer>; // error +} diff --git a/tests/java5/generics/itds/A.java b/tests/java5/generics/itds/A.java new file mode 100644 index 000000000..f75d7f90a --- /dev/null +++ b/tests/java5/generics/itds/A.java @@ -0,0 +1,21 @@ +public class A { + public static void main(String[] argv) { + Integer two = 2; + Integer four= 4; + System.err.println("min(2,4)=>"+ new Utils().min(two,four)); + System.err.println("max(2,4)=>"+new Utils().max(two,four)); + } +} + + +aspect X { + <T extends Number> T Utils.max(T first,T second) { + if (first>second) return first; else return second; + } +} + +class Utils { + <T extends Number> T min(T first,T second) { + if (first.intValue()<second.intValue()) return first; else return second; + } +} diff --git a/tests/java5/generics/itds/B.java b/tests/java5/generics/itds/B.java new file mode 100644 index 000000000..321d828b7 --- /dev/null +++ b/tests/java5/generics/itds/B.java @@ -0,0 +1,21 @@ +public class B { + public static void main(String[] argv) { + Integer two = 2; + Integer four= 4; + System.err.println("min(2,4)=>"+ Utils.min(two,four)); + System.err.println("max(2,4)=>"+Utils.max(two,four)); + } +} + + +aspect X { + static <T extends Number> T Utils.max(T first,T second) { + if (first>second) return first; else return second; + } +} + +class Utils { + static <T extends Number> T min(T first,T second) { + if (first.intValue()<second.intValue()) return first; else return second; + } +} diff --git a/tests/java5/generics/itds/C.java b/tests/java5/generics/itds/C.java new file mode 100644 index 000000000..536b6a843 --- /dev/null +++ b/tests/java5/generics/itds/C.java @@ -0,0 +1,8 @@ +// Using type parameter in ITD +public abstract aspect C<T> { + private T Foo.data; + + public T Foo.getData(T defaultValue) { + return (this.data!=null?data:defaultValue); + } +} diff --git a/tests/java5/generics/itds/D.java b/tests/java5/generics/itds/D.java new file mode 100644 index 000000000..2ab496cc0 --- /dev/null +++ b/tests/java5/generics/itds/D.java @@ -0,0 +1,11 @@ +public abstract aspect D<T> { + + private T Goo<T>.data; + + public T Goo<T>.getData(T defaultValue) { + return (this.data != null ? data : defaultValue); + } + +} + +class Goo<P> {} diff --git a/tests/java5/generics/itds/Parse1.java b/tests/java5/generics/itds/Parse1.java new file mode 100644 index 000000000..7168e15a9 --- /dev/null +++ b/tests/java5/generics/itds/Parse1.java @@ -0,0 +1,6 @@ +// Simple non-static ITDM +public class Parse1 { } + +aspect X { + <T> T Parse1.m(T) {} +} diff --git a/tests/java5/generics/itds/Parse2.java b/tests/java5/generics/itds/Parse2.java new file mode 100644 index 000000000..2764904cb --- /dev/null +++ b/tests/java5/generics/itds/Parse2.java @@ -0,0 +1,6 @@ +// Simple static ITDM +public class Parse2 { } + +aspect X { + static <T> T Parse2.m(T) {} +} diff --git a/tests/java5/generics/itds/Parse3.java b/tests/java5/generics/itds/Parse3.java new file mode 100644 index 000000000..2b9aab491 --- /dev/null +++ b/tests/java5/generics/itds/Parse3.java @@ -0,0 +1,6 @@ +// Simple ITDC +public class Parse1 { } + +aspect X { + <T> T Parse1.new(T) {} +} diff --git a/tests/java5/generics/itds/Parse4.java b/tests/java5/generics/itds/Parse4.java new file mode 100644 index 000000000..685356e8a --- /dev/null +++ b/tests/java5/generics/itds/Parse4.java @@ -0,0 +1,8 @@ +import java.util.*; + +// Complex ITDM +public class Parse1 { } + +aspect X { + <T> Parse1.sort(List<T> elements,Comparator<? super T> comparator) {} +} diff --git a/tests/java5/generics/itds/Parse5.java b/tests/java5/generics/itds/Parse5.java new file mode 100644 index 000000000..c322f006d --- /dev/null +++ b/tests/java5/generics/itds/Parse5.java @@ -0,0 +1,16 @@ +// ITDs on generic types +public class Parse5<T,S extends Number> {} + +aspect X { + String Parse5.m1() {} + + String Parse5<Q,R extends Number>.m2() {} + + String Parse5<T,V>.m3() {} // error + + String Parse5<A,B extends Number,C>.m4() {} // error + + String Parse5<A>.m5() {} // error + + String Parse5<String,Integer>.m6() {} // error +} |