Community
Participate
Working Groups
Created attachment 272660 [details] Test case class See the attachment; the attached class (inserted in a plain Java project) won't compile in Eclipse; however it compiles and run without errors on both Netbeans and IntelliJ. Compilation error is: Exception in thread "main" java.lang.Error: Unresolved compilation problems: Type mismatch: cannot convert from List<AbstractMap.SimpleEntry<Object,String>> to List<Map.Entry<OneLinerMapInitializer.MapStrategy,String>> The target type of this expression must be a functional interface The target type of this expression must be a functional interface The target type of this expression must be a functional interface at OneLinerMapInitializer.main(OneLinerMapInitializer.java:22)
Thanks, I can see that ecj rejects and javac accepts this. From a quick glance it's hard to tell which is the correct behavior. Seeing a functional interfaces with wildcards, javac's bug re wildcard widening [1] could have a finger in the pie, but more importantly: The use of raw types puts this example into an area, where javac, JLS and ecj are known to deviate in ways which may be impossible to resolve without changes in JLS. For further analysis I added missing type information to yield a program that ecj accepts: //--- import java.util.*; public class OneLinerMapInitializer { @FunctionalInterface public interface MapStrategy {Map<?,?> getMap();} public static Map<?,String> getMap1() { return null; } public static Map<?,String> getMap2() { return null; } public static Map<?,String> getMap3() { return null; } public static void main(String[] args) { final List<Map.Entry<MapStrategy,String>> lll = Arrays.asList( new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap1,""), new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap2,""), new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap3,"") ); } } //--- Obviously, this version can be used by clients as a workaround. What's fishy now: omitting the explicit type arguments of the SimpleEntry contructor invocations (to use diamonds) makes ecj fail again. The same difference can be exhibited even without wildcards: //--- import java.util.*; public class OneLinerMapInitializer { @FunctionalInterface public interface MapStrategy {Map<Object,String> getMap();} public static Map<Object,String> getMap1() { return null; } public static Map<Object,String> getMap2() { return null; } public static Map<Object,String> getMap3() { return null; } public static void main(String[] args) { final List<Map.Entry<MapStrategy,String>> lll = Arrays.asList( new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap1,""), new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap2,""), new AbstractMap.SimpleEntry<MapStrategy,String>(OneLinerMapInitializer::getMap3,"") ); } } //--- Same as above: accepted by ecj but rejected when changed to use diamonds. With no influence of wildcards nor raw types this sure looks like a bug in ecj. [1] https://bugs.openjdk.java.net/browse/JDK-8016207
bulk move out of 4.8
Bulk move out of 4.9
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.