The type of int.class is Class<Integer>.
This basically destroys the type safety purported by type tokens:
import java.util.*;
class Test {
public static void main(String[] args) {
Collection<Integer> c = new Vector<Integer>();
c = Collections.checkedCollection(c, int.class);
c.add(0);
}
}
This program fails:
Exception in thread "main" java.lang.ClassCastException: Attempt to insert class java.lang.Integer element into collection with element type int
at java.util.Collections$CheckedCollection.typeCheck(Collections.java:2206)
at java.util.Collections$CheckedCollection.add(Collections.java:2240)
at Test.main(Test.java:7)
###@###.### 10/20/04 06:31 GMT