Can a warning be avoided uncheckedwhen typing an object with a parameterized type? For example, below the actual situation that I am facing var1is of the type JComboBox<RandomType>I want to save it in Map, and then return it to the next situation.
JComboBox<RandomType> var1 = new JComboBox<RandomType>();
Object varRaw = var1;
JComboBox<RandomType> var2 = (JComboBox<RandomType>) varRaw;
JComboBox<RandomType> var3;
if (JComboBox.class.isAssignableFrom(varRaw.getClass())) {
var3 = JComboBox.class.cast(varRaw);
}
Both regular castings and conditional castings lead to the same warning.
Is it possible to avoid this warning at all in this situation without using annotation @SuppressWarnings?
source
share