I've finally got around to trying to get rid of all those new compiler warnings that Java 7 has kindly generated. I these two left that I cannot fathom. Is there any way of getting rid of them without suppressing them?
Constructing an array of generically typed objects (where can I put a in the array creation?):
static final int N = 10;
//warning: [unchecked] unchecked conversion
static final Set<Widget>[] queued = new ConcurrentSkipListSet[N];
//required: Set<Widget>[]
//found: ConcurrentSkipListSet[]
Generic varargs (Seems to happen almost everywhere I accept varargs of a generic type):
class Foo<T> {
//warning: [unchecked] Possible heap pollution from parameterized vararg type T
public void add(T... entries) {
//where T is a type-variable:
//T extends Object declared in class Foo
BTW: I already have:
// Add many entries to the list.
public void add(List<T> entries) {
// ...
}
// Add a number of entries.
public void add(T... entries) {
// Make a list of them.
add(Arrays.<T>asList(entries));
}