Given:
import com.google.common.collect.ImmutableMap; import java.util.function.Function; import java.util.stream.Collector; import java.util.stream.Stream;
There's another way to fix this. You can give a hint to compiler explicitly specifying the argument type for identity lambda:
ImmutableMap map2 = Stream.of("1", "2", "3") .collect(Testcase.toImmutableMap((String i) -> i, Integer::valueOf).build());
Compiles fine in Javac 1.8.0_25 and ECJ 3.10.2.