Reputation: 7383
The following code fails to compile on Eclipse Neon 4.6.0 :
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class Test {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) {
Map rawMap = new HashMap();
Map<String, Integer> map = new HashMap<>(rawMap); // Type mismatch: cannot convert from HashMap to Map<String, Integer>
map = Collections.synchronizedMap(rawMap); // No error here
}
}
The exact same code compiles fine when invoking javac (1.8) from the command line. It also works on older versions of Eclipse (Mars 2). What is the issue here?
Upvotes: 0
Views: 1353