Here is the code:
class Foo<T> {
private final T[] array;
@SafeVarargs
Foo(T... items) {
this.array = items;
}
}
I get:
[WARNING] Varargs method could cause heap pollution
from non-reifiable varargs parameter items
What happened to my assignment? How to fix it? @SuppressWarningsis not an option, as I want this constructor to be truly "safe".
$ javac -version
javac 1.8.0_40
source
share