What is an apparently correct example of Java code causing heap pollution?
问题 I'm trying to decide what to do every time I get a Java heap pollution warning when using parameterized varargs such as in public static <T> LinkedList<T> list(T... elements) { ... } It seems to me that if I am confident not to be using some weird casts in my methods, I should just use @SafeVarargs and move on. But is this correct, or do I need to be more careful? Is there apparently correct code that is actually not safe when using parameterized varargs? Reading about the subject, I notice