aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/generics
diff options
context:
space:
mode:
authoraclement <aclement>2005-08-15 09:27:16 +0000
committeraclement <aclement>2005-08-15 09:27:16 +0000
commit012ff4d7009a28cf8754cd1804936a5824f53312 (patch)
treea8b0818feacff75ccf4369400e6b1c2116045daf /tests/java5/generics
parent97eb517e2c79764c5a5eeef4b03b7ef21f75900d (diff)
downloadaspectj-012ff4d7009a28cf8754cd1804936a5824f53312.tar.gz
aspectj-012ff4d7009a28cf8754cd1804936a5824f53312.zip
genericitds: more method/ctor ITDs that use their target types generic type variables. plus some basic generic aspects that combine the building blocks
Diffstat (limited to 'tests/java5/generics')
-rw-r--r--tests/java5/generics/itds/sharing/CtorC.aj15
-rw-r--r--tests/java5/generics/itds/sharing/CtorD.aj14
-rw-r--r--tests/java5/generics/itds/sharing/CtorE.aj16
-rw-r--r--tests/java5/generics/itds/sharing/CtorF.aj15
-rw-r--r--tests/java5/generics/itds/sharing/CtorG.aj20
-rw-r--r--tests/java5/generics/itds/sharing/CtorH.aj19
-rw-r--r--tests/java5/generics/itds/sharing/CtorI.aj14
-rw-r--r--tests/java5/generics/itds/sharing/GenericAspectA.aj19
-rw-r--r--tests/java5/generics/itds/sharing/GenericAspectB.aj19
-rw-r--r--tests/java5/generics/itds/sharing/GenericAspectC.aj24
-rw-r--r--tests/java5/generics/itds/sharing/GenericAspectD.aj24
-rw-r--r--tests/java5/generics/itds/sharing/GenericAspectE.aj18
12 files changed, 217 insertions, 0 deletions
diff --git a/tests/java5/generics/itds/sharing/CtorC.aj b/tests/java5/generics/itds/sharing/CtorC.aj
new file mode 100644
index 000000000..967c38192
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorC.aj
@@ -0,0 +1,15 @@
+import java.util.*;
+
+public class CtorC {
+ public static void main(String []argv) {
+ List<List<Integer>> intList2 = new ArrayList<List<Integer>>();
+ Base b = new Base(intList2);
+ }
+}
+
+class Base<N extends Number> {
+}
+
+aspect X {
+ public Base<Z>.new(List<List<Z>> llz) {}; // ok - nested but OK
+}
diff --git a/tests/java5/generics/itds/sharing/CtorD.aj b/tests/java5/generics/itds/sharing/CtorD.aj
new file mode 100644
index 000000000..f8115ce92
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorD.aj
@@ -0,0 +1,14 @@
+import java.util.*;
+
+public class CtorD {
+ public static void main(String []argv) {
+ Base b = new Base(new HashMap<Double,String>());
+ }
+}
+
+class Base<N extends Number,S> {
+}
+
+aspect X {
+ public Base<A,B>.new(Map<A,B> mabs) {}; // ok multiple
+}
diff --git a/tests/java5/generics/itds/sharing/CtorE.aj b/tests/java5/generics/itds/sharing/CtorE.aj
new file mode 100644
index 000000000..20aaf57d6
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorE.aj
@@ -0,0 +1,16 @@
+import java.util.*;
+
+public class CtorE {
+ public static void main(String []argv) {
+ Base<Integer> base = new Base<Integer>();
+ List<String> stringList = new ArrayList<String>();
+ Base b = new Base(stringList);
+ }
+}
+
+class Base<N extends Number> {
+}
+
+aspect X {
+ public Base<Z>.new(List<String> ls) {}; // ok - specified type variable but didnt use it (could put a lint warning on this case?)
+}
diff --git a/tests/java5/generics/itds/sharing/CtorF.aj b/tests/java5/generics/itds/sharing/CtorF.aj
new file mode 100644
index 000000000..bb4204b5b
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorF.aj
@@ -0,0 +1,15 @@
+import java.util.*;
+
+public class CtorF {
+ public static void main(String []argv) {
+
+ Base b = new Base(new HashMap<String,Float>(),new HashMap<Double,Float>());
+ }
+}
+
+class Base<P,N extends Number,S> {
+}
+
+aspect X {
+ public Base<A,B,C>.new(Map<C,A> lc,Map<B,A> lb) {} // ok multiple in funny orders
+}
diff --git a/tests/java5/generics/itds/sharing/CtorG.aj b/tests/java5/generics/itds/sharing/CtorG.aj
new file mode 100644
index 000000000..d798f9c7f
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorG.aj
@@ -0,0 +1,20 @@
+import java.util.*;
+
+public aspect CtorG {
+
+ // visibility options...
+ public Base<Z>.new(List<Z> lz,int i) {}
+ private Base<Z>.new(List<Z> lz,String s) {}
+ Base<Z>.new(List<Z> lz,boolean b) {}
+
+ public static void main(String []argv) {
+ List<Integer> intList = new ArrayList<Integer>();
+ Base b1 = new Base(intList,1);
+// Base b2 = new Base(intList,"a");
+ Base b3 = new Base(intList,true);
+ }
+}
+
+class Base<N extends Number> {
+
+}
diff --git a/tests/java5/generics/itds/sharing/CtorH.aj b/tests/java5/generics/itds/sharing/CtorH.aj
new file mode 100644
index 000000000..8ce2d0ffe
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorH.aj
@@ -0,0 +1,19 @@
+import java.util.*;
+
+public class CtorH {
+ public static void main(String []argv) {
+ Base<Integer> baseInt = new Base<Integer>();
+ Base<String> baseString = new Base<String>();
+
+ List<Integer> intList = new ArrayList<Integer>();
+ List<String> strList = new ArrayList<String>();
+ Base b1 = new Base(intList);
+ Base b2 = new Base(strList);
+ }
+}
+
+class Base<N> { }
+
+aspect X {
+ public Base<Z>.new(List<Z> lz) {} // OK, Z becomes N in first case, S in the second ;)
+}
diff --git a/tests/java5/generics/itds/sharing/CtorI.aj b/tests/java5/generics/itds/sharing/CtorI.aj
new file mode 100644
index 000000000..bed64a85a
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/CtorI.aj
@@ -0,0 +1,14 @@
+import java.util.*;
+
+public class CtorI {
+ public static void main(String []argv) {
+ List<String> ls = new ArrayList<String>();
+ Base b = new Base(ls); // error, violates bounds
+ }
+}
+
+class Base<N extends Number> { }
+
+aspect X {
+ public Base<Z>.new(List<Z> lz) {}
+}
diff --git a/tests/java5/generics/itds/sharing/GenericAspectA.aj b/tests/java5/generics/itds/sharing/GenericAspectA.aj
new file mode 100644
index 000000000..fcb3090ea
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/GenericAspectA.aj
@@ -0,0 +1,19 @@
+// Simple - adding an interface to a type via a generic aspect and decp
+abstract aspect GenericAspect<A> {
+
+ declare parents: A implements SimpleI;
+
+ interface SimpleI {}
+
+}
+
+aspect GenericAspectA extends GenericAspect<Base> {
+ public static void main(String []argv) {
+ Base b = new Base();
+ if (!(b instanceof SimpleI))
+ throw new RuntimeException("Base should implement SimpleI!");
+ }
+}
+
+class Base {}
+
diff --git a/tests/java5/generics/itds/sharing/GenericAspectB.aj b/tests/java5/generics/itds/sharing/GenericAspectB.aj
new file mode 100644
index 000000000..39d262223
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/GenericAspectB.aj
@@ -0,0 +1,19 @@
+// Decp a generic interface
+abstract aspect GenericAspect<A> {
+
+ declare parents: A implements SimpleI;
+
+ interface SimpleI<X> {}
+
+}
+
+aspect GenericAspectB extends GenericAspect<Base> {
+ public static void main(String []argv) {
+ Base b = new Base();
+ if (!(b instanceof SimpleI))
+ throw new RuntimeException("Base should implement SimpleI!");
+ }
+}
+
+class Base {}
+
diff --git a/tests/java5/generics/itds/sharing/GenericAspectC.aj b/tests/java5/generics/itds/sharing/GenericAspectC.aj
new file mode 100644
index 000000000..3e1d6c6ee
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/GenericAspectC.aj
@@ -0,0 +1,24 @@
+// Decp an interface with an ITD method on it
+abstract aspect GenericAspect<A> {
+
+ interface SimpleI {}
+
+ declare parents: A implements SimpleI;
+
+ public int SimpleI.m() { return 4;}
+
+}
+
+aspect GenericAspectC extends GenericAspect<Base> {
+ public static void main(String []argv) {
+ Base b = new Base();
+
+ if (!(b instanceof SimpleI))
+ throw new RuntimeException("Base should implement SimpleI!");
+
+ int i = b.m();
+ }
+}
+
+class Base {}
+
diff --git a/tests/java5/generics/itds/sharing/GenericAspectD.aj b/tests/java5/generics/itds/sharing/GenericAspectD.aj
new file mode 100644
index 000000000..30775a593
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/GenericAspectD.aj
@@ -0,0 +1,24 @@
+// Decp an interface with an ITD field
+abstract aspect GenericAspect<A> {
+
+ interface SimpleI {}
+
+ declare parents: A implements SimpleI;
+
+ public int SimpleI.n;
+
+}
+
+aspect GenericAspectD extends GenericAspect<Base> {
+ public static void main(String []argv) {
+ Base b = new Base();
+
+ if (!(b instanceof SimpleI))
+ throw new RuntimeException("Base should implement SimpleI!");
+
+ b.n=42;
+ }
+}
+
+class Base {}
+
diff --git a/tests/java5/generics/itds/sharing/GenericAspectE.aj b/tests/java5/generics/itds/sharing/GenericAspectE.aj
new file mode 100644
index 000000000..60bf8cd53
--- /dev/null
+++ b/tests/java5/generics/itds/sharing/GenericAspectE.aj
@@ -0,0 +1,18 @@
+abstract aspect GenericAspect<A> {
+
+ declare parents: A implements IUtil;
+
+ //public void IUtil<Z>.print(Z n) { System.err.println(n); }
+}
+
+interface IUtil<N extends Number> { }
+
+aspect GenericAspectE extends GenericAspect<Base> {
+ public static void main(String []argv) {
+ Base b = new Base();
+ // b.print("hello");
+ }
+}
+
+class Base {}
+