Possible Bug in javac resolving method references.

taichi sato ryushi at gmail.com
Sun Oct 5 10:57:12 UTC 2014

Hi, I wrote code the below.


javac says me below

src\example\Main.java:13: error: reference to of is ambiguous
  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;
  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
2 errors

i think this is bug because eclipse jdt compiler can compile the code and

* first exec method has return type and one argument,
  OutputStreamConsumer and WriterConsumer require 2 argument and no return
  so this is not ambiguous. i think  compiler should pick a second exec
* OutputStreamConsumer receives OutputStream, not Appendable.
   so compiler should pick WriterConsumer

my envrionment is below

* javac 1.8.0_20
* eclipse 4.4.0


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20141005/68caa113/attachment.html>

More information about the compiler-dev mailing list