aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2005-08-08 08:33:09 +0000
committeraclement <aclement>2005-08-08 08:33:09 +0000
commit7e71de736f50a564628a7b04b36f2b6d07f73b5a (patch)
treeb5d16bf943b63d2c0240b8de83519e7ee399e7e0 /tests
parent8f4da67cd5008837d59c6a182558b8403cbff58a (diff)
downloadaspectj-7e71de736f50a564628a7b04b36f2b6d07f73b5a.tar.gz
aspectj-7e71de736f50a564628a7b04b36f2b6d07f73b5a.zip
genericitds: test programs
Diffstat (limited to 'tests')
-rw-r--r--tests/java5/generics/itds/BizarroSignatures.aj55
-rw-r--r--tests/java5/generics/itds/sharing/Simple.aj30
-rw-r--r--tests/java5/generics/itds/sharing/Simple2.aj28
-rw-r--r--tests/java5/generics/itds/visibility/PackageITDs.aj30
-rw-r--r--tests/java5/generics/itds/visibility/PrivateITDs.aj30
-rw-r--r--tests/java5/generics/itds/visibility/PublicITDs.aj35
-rw-r--r--tests/java5/generics/itds/visibility/PublicITDsErrors.aj29
7 files changed, 237 insertions, 0 deletions
diff --git a/tests/java5/generics/itds/BizarroSignatures.aj b/tests/java5/generics/itds/BizarroSignatures.aj
new file mode 100644
index 000000000..03b683625
--- /dev/null
+++ b/tests/java5/generics/itds/BizarroSignatures.aj
@@ -0,0 +1,55 @@
+import java.util.*;
+
+class Victim {}
+
+public class BizarroSignatures {
+ public static void main(String []argv) {
+ Victim v = new Victim();
+
+ Map<Double,Double> m = new HashMap<Double,Double>();
+ v.a(m);
+
+ List<A> as = new ArrayList<A>();
+ v.b(as);
+ v.c(as);
+
+ //v.c(as);
+
+ }
+
+}
+
+class A implements Comparable<A> {
+ public int compareTo(A a) { return 0; }
+}
+
+aspect X {
+
+ public void Victim.a(Map<?,? extends Number> map) {}
+
+ public <T extends Object & Comparable<? super T>>
+ void Victim.b(List<T> l) {}
+
+ public <P extends Object & Comparable<? super P>>
+ void Victim.c(List<P> col) {};//return null;}
+
+// public <T extends Comparable<? super Number>>
+// T Victim.d(Collection<T> col) {return null;}
+//
+// public <T extends Comparable<T>>
+// T Victim.e(Collection<T> col) {return null;}
+//
+// public <X>
+// X Victim.f(Collection<X> x) {return null;}
+//
+// public void Victim.g(List<List<List<List<List<? extends List>>>>> wtf) {}
+//
+// public <T>
+// void Victim.h(List <T> a,List<? extends T> b) {}
+//
+// public <T extends Number>
+// void Victim.i(Map<T,? super Number> n) {}
+
+// public <T>
+// void Victim.j(T[] ts,Collection<T> c) {}
+}
diff --git a/tests/java5/generics/itds/sharing/Simple.aj b/tests/java5/generics/itds/sharing/Simple.aj
new file mode 100644
index 000000000..0c328ed34
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/Simple.aj
@@ -0,0 +1,30 @@
+public class Simple {
+ public static void main(String []argv) {
+ Base<Integer> base = new Base<Integer>();
+ List<Integer> intList = new ArrayList<Integer>();
+ intList.add(5);
+ intList.add(2);
+ intList.add(3);
+ intList.add(8);
+ System.err.println(">"+base.m(intList));
+ System.err.println(">"+base.m2(intList));
+ }
+}
+
+
+
+class Base<N extends Number> {
+
+ public int m(List<N> ns) {
+ return ns.size();
+ }
+
+}
+
+aspect X {
+
+ public int Base<Z>.m2(List<Z> zs) {
+ return zs.size();
+ }
+}
+
diff --git a/tests/java5/generics/itds/sharing/Simple2.aj b/tests/java5/generics/itds/sharing/Simple2.aj
new file mode 100644
index 000000000..50cac3ee7
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/Simple2.aj
@@ -0,0 +1,28 @@
+public class Simple2 {
+ public static void main(String []argv) {
+ Base<Integer> base = new Base<Integer>();
+ List<Integer> intList = new ArrayList<Integer>();
+ intList.add(5);
+ base.f1 = intList;
+ base.copy();
+ System.err.println("f2.get(0)=>"+f2.get(0));
+ }
+}
+
+
+
+class Base<N extends Number> {
+
+ public List<N> f1;
+
+}
+
+aspect X {
+
+ public List<Z> Base<Z>.f2;
+
+ public void Base.copy() {
+ f2=f1;
+ }
+}
+
diff --git a/tests/java5/generics/itds/visibility/PackageITDs.aj b/tests/java5/generics/itds/visibility/PackageITDs.aj
new file mode 100644
index 000000000..eaa7f3122
--- /dev/null
+++ b/tests/java5/generics/itds/visibility/PackageITDs.aj
@@ -0,0 +1,30 @@
+import java.util.*;
+
+class Base {
+
+}
+
+public aspect PackageITDs {
+
+ public static void main(String[] argv) {
+ List<Double> l1 = new ArrayList<Double>();
+ Base b = new Base();
+ b.packageMethod1(l1);
+ b.packageMethod2(l1,l1);
+ Base b2 = new Base(l1);
+ Base b3 = new Base(l1,l1);
+ Map<Integer,Double> m1 = new HashMap<Integer,Double>();
+ Base b4 = new Base(l1,m1);
+ }
+
+
+ // methods
+ <R extends Number> void Base.packageMethod1(List<R> lr) {}
+ <R extends Number> void Base.packageMethod2(List<R> lr1,List<R> lr2) {}
+
+ // ctor
+ <P extends Number> Base.new(List<P> lr) {}
+ <P extends Number> Base.new(List<P> lr1,List<P> lr2) {}
+ <P,Q extends Number> Base.new(List<P> lp,Map<Q,P> m1) {}
+
+}
diff --git a/tests/java5/generics/itds/visibility/PrivateITDs.aj b/tests/java5/generics/itds/visibility/PrivateITDs.aj
new file mode 100644
index 000000000..beaebb49d
--- /dev/null
+++ b/tests/java5/generics/itds/visibility/PrivateITDs.aj
@@ -0,0 +1,30 @@
+import java.util.*;
+
+class Base {
+
+}
+
+public aspect PrivateITDs {
+
+ public static void main(String[] argv) {
+ List<Double> l1 = new ArrayList<Double>();
+ Base b = new Base();
+ b.privateMethod1(l1);
+ b.privateMethod2(l1,l1);
+ Base b2 = new Base(l1);
+ Base b3 = new Base(l1,l1);
+ Map<Integer,Double> m1 = new HashMap<Integer,Double>();
+ Base b4 = new Base(l1,m1);
+ }
+
+
+ // methods
+ private <R extends Number> void Base.privateMethod1(List<R> lr) {}
+ private <R extends Number> void Base.privateMethod2(List<R> lr1,List<R> lr2) {}
+
+ // ctor
+ private <P extends Number> Base.new(List<P> lr) {}
+ private <P extends Number> Base.new(List<P> lr1,List<P> lr2) {}
+ private <P,Q extends Number> Base.new(List<P> lp,Map<Q,P> m1) {}
+
+}
diff --git a/tests/java5/generics/itds/visibility/PublicITDs.aj b/tests/java5/generics/itds/visibility/PublicITDs.aj
new file mode 100644
index 000000000..25d58b4a3
--- /dev/null
+++ b/tests/java5/generics/itds/visibility/PublicITDs.aj
@@ -0,0 +1,35 @@
+import java.util.*;
+
+class Base {
+
+}
+
+public class PublicITDs {
+
+ public static void main(String[] argv) {
+ List<Double> l1 = new ArrayList<Double>();
+ Base b = new Base();
+ b.publicMethod1(l1);
+ b.publicMethod2(l1,l1);
+ Base b2 = new Base(l1);
+ Base b3 = new Base(l1,l1);
+ Map<Integer,Double> m1 = new HashMap<Integer,Double>();
+ Base b4 = new Base(l1,m1);
+ }
+
+}
+
+aspect X {
+
+ // methods
+ public <R extends Number> void Base.publicMethod1(List<R> lr) {}
+ public <R extends Number> void Base.publicMethod2(List<R> lr1,List<R> lr2) {}
+
+ // ctor
+ public <P extends Number> Base.new(List<P> lr) {}
+ public <P extends Number> Base.new(List<P> lr1,List<P> lr2) {}
+ public <P,Q extends Number> Base.new(List<P> lp,Map<Q,P> m1) {}
+
+ // what use is this next one??
+ // public <R extends Number> R Base.publicMethod3() { return null;}
+}
diff --git a/tests/java5/generics/itds/visibility/PublicITDsErrors.aj b/tests/java5/generics/itds/visibility/PublicITDsErrors.aj
new file mode 100644
index 000000000..cc7bd81cf
--- /dev/null
+++ b/tests/java5/generics/itds/visibility/PublicITDsErrors.aj
@@ -0,0 +1,29 @@
+import java.util.*;
+
+class Base {
+
+}
+
+public class PublicITDsErrors {
+
+ public static void main(String[] argv) {
+ List<Double> l1 = new ArrayList<Double>();
+ List<Float> l2 = new ArrayList<Float>();
+ Base b = new Base();
+ b.publicMethod2(l1,l2); // CE attempt to bind tvar to Float & Double
+ Map<Integer,String> m1 = new HashMap<Integer,String>();
+ Base b4 = new Base(l1,m1); // CE attempt to bind tvarP to Double and String
+ }
+
+}
+
+aspect X {
+ // methods
+ public <R extends Number> void Base.publicMethod1(List<R> lr) {}
+ public <R extends Number> void Base.publicMethod2(List<R> lr1,List<R> lr2) {}
+
+ // ctor
+ public <P extends Number> Base.new(List<P> lr) {}
+ public <P extends Number> Base.new(List<P> lr1,List<P> lr2) {}
+ public <P,Q extends Number> Base.new(List<P> lp,Map<Q,P> m1) {}
+}