]> source.dussan.org Git - aspectj.git/commitdiff
sick sick sick generic itd tests.
authoraclement <aclement>
Tue, 26 Jul 2005 14:17:04 +0000 (14:17 +0000)
committeraclement <aclement>
Tue, 26 Jul 2005 14:17:04 +0000 (14:17 +0000)
tests/java5/generics/itds/MethodITDOnGeneric.aj [new file with mode: 0644]
tests/java5/generics/itds/StaticFieldITDOnGeneric.aj [new file with mode: 0644]
tests/java5/generics/itds/StaticMethodITDOnGenericType.aj [new file with mode: 0644]

diff --git a/tests/java5/generics/itds/MethodITDOnGeneric.aj b/tests/java5/generics/itds/MethodITDOnGeneric.aj
new file mode 100644 (file)
index 0000000..ce02433
--- /dev/null
@@ -0,0 +1,5 @@
+class C<A,B> { public B getB(A a) { return null; } }
+
+aspect X {
+  public List<C> C<D,C>.getBs(D ds) { return null; }
+}
diff --git a/tests/java5/generics/itds/StaticFieldITDOnGeneric.aj b/tests/java5/generics/itds/StaticFieldITDOnGeneric.aj
new file mode 100644 (file)
index 0000000..44194fa
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Static ITD of a field onto a generic type that utilises
+ * a type variable from the target generic
+ */
+import java.util.*;
+
+class MathUtils<N> { 
+
+}
+
+public class StaticFieldITDOnGenericType {
+  public static void main(String[] argv) {
+    MathUtils<Integer>.n=42;
+    System.err.prinltn(">"+MathUtils<Integer>.n);
+  }
+}
+
+aspect X {
+  static E MathUtils<E>.n;
+}
diff --git a/tests/java5/generics/itds/StaticMethodITDOnGenericType.aj b/tests/java5/generics/itds/StaticMethodITDOnGenericType.aj
new file mode 100644 (file)
index 0000000..91b51a6
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Static ITD of a method onto a generic type that utilises
+ * a type variable from the target generic
+ */
+import java.util.*;
+
+class MathUtils<N> { 
+
+  public N doubleIt(N n) {
+    int i = Integer.parseInt(n);
+    return i*2;
+  }
+
+}
+
+public class StaticMethodITDOnGenericType {
+  public static void main(String[] argv) {
+    List<Integer> ints = new ArrayList<Integer>();
+    ints.add(10); 
+    System.err.println("Double(10)=" + MathUtils<Integer>.doubleIt(5));
+    System.err.println("First="      + MathUtils.first(ints));
+  }
+}
+
+
+aspect X {
+  // Using the type variable from the type. this is not a generic method.
+  static E MathUtils<E>.first(List<E> elements) { return elements.get(0); }
+}