I'm using set for defining allowed keys for some action. Eclipse shows this warning:
Type safety: The expression of type List needs unchecked conversion
to conform to Collection<? extends Object>
I googled a bit and found same message in slightly different cases but its probably similar problem.
Is any chance get rid of this warning other way then
@SuppressWarnings("unchecked")
Is good idea to use
@SuppressWarnings("unchecked")
in this case?
Here is my code:
public static final String KEY_A = "A_VALUE";
public static final String KEY_B = "B_VALUE";
public static final Set<?> allowedKeys = new HashSet<Object>(Arrays.asList(new String[] {KEY_A, KEY_B}));
Eclipse did the mess:
Wrong:
import edu.emory.mathcs.backport.java.util.Arrays;
Correct:
import jave.util.Arrays;
So code is ok both versions Set<?>
and Set<String>
. Eclipse just auto imported bad class.