In Java 1.7.0_55, if I write this field declaration, I get a compilation error (\"incompatible types\"):
private final Map myMap =
This fails with your compiler error in Java 7, but it compiles successfully in Java 8. In short, the compiler's type inference did not catch the proper inferred types in Java 7, but the better type inference infers the proper types in Java 8.
This change was JEP (JDK Enhancement Proposal) 101 for Java 8.
Summary
Smoothly expand the scope of method type-inference to support (i) inference in method context and (ii) inference in chained calls.
Java 8 is able to infer types through multiple method calls with parameters and method call chaining. It can now determine from the left side of the assignment through the call to Collections.synchronizedMap to the diamond operator in the parameter to that call, new HashMap<>().