Diamond + rawtype不会在eclipse上编译

时间:2016-07-12 07:31:16

标签: java eclipse compiler-errors raw-types diamond-operator

以下代码无法在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
   }

}

从命令行调用javac(1.8)时,完全相同的代码编译正常。它也适用于旧版本的Eclipse(Mars 2)。这是什么问题?

0 个答案:

没有答案