Last active
August 29, 2015 14:07
-
-
Save taichi/f676381bd148bd497106 to your computer and use it in GitHub Desktop.
javac bug. java8u20 compiler cannot compile this code. but eclipse4.4.0 compiler can compile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src\example\Main.java:13: error: reference to of is ambiguous | |
Consumers.of(Main::exec); | |
^ | |
both method of(OutputStreamConsumer) in Consumers and method of(WriterConsumer) in Consumers match | |
src\example\Main.java:13: error: method of in interface Consumers cannot be applied to given types; | |
Consumers.of(Main::exec); | |
^ | |
required: OutputStreamConsumer | |
found: Main::exec | |
reason: argument mismatch; invalid method reference | |
no suitable method found for exec(Object,OutputStream) | |
method Main.exec(Object) is not applicable | |
(actual and formal argument lists differ in length) | |
method Main.exec(Object,Appendable) is not applicable | |
(argument mismatch; OutputStream cannot be converted to Appendable) | |
2 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.OutputStream; | |
import java.io.Writer; | |
public class Main { | |
public static String exec(Object value) { return null; } | |
public static void exec(Object value, Appendable appendable) {} | |
public static void main(String[] args) { | |
Consumers.of(Main::exec); | |
} | |
public interface Consumers { | |
public static void of(OutputStreamConsumer fn) {} | |
public static void of(WriterConsumer fn) {} | |
public interface OutputStreamConsumer { | |
void render(Object model, OutputStream out); | |
} | |
public interface WriterConsumer { | |
void render(Object model, Writer out); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment