blob: af75f07dc65fa3a29b268b3136f5bf79ea032299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/*
* Static ITD of a generic method
*/
import java.util.*;
class MathUtils {
}
public class StaticGenericMethodITD {
public static void main(String[] argv) {
List<Integer> ints = new ArrayList<Integer>();
ints.add(10); ints.add(20); ints.add(30);
System.err.println("First="+MathUtils.first(ints));
if (!MathUtils.first(ints).equals(10))
throw new RuntimeException("First val!=10, it was "+
MathUtils.first(ints));
}
}
aspect X {
static <E> E MathUtils.first(List<E> elements) { return elements.get(0); }
}
|