java - A functional interface that extends other can't - can't assign constructor reference to it - Is it compiler bug? -
in simple code below can see 'factory' interfaces, different between them factory0bad
extends supplier
:
@functionalinterface public static interface factory0bad<t> extends supplier<t> { t get(); } @functionalinterface public static interface factory0good<t> { t get(); } public static class handler {} public static class handlera extends handler {} public static void main(string[] args) { // line compiles factory0good<? extends handler> = handlera::new; // not! factory0bad<? extends handler> bad = handlera::new; }
so line
factory0good<? extends handler> = handlera::new;
is accepted compiler (1.8.0u05), line
factory0bad<? extends handler> bad = handlera::new;
is not.
why this? missing here? bug in javac?
// not! // 1.8.0_05 - fails // 1.8.0_40 - succeeds // 1.8.0_45 - succeeds factory0bad<? extends handler> bad = handlera::new;
Comments
Post a Comment