Varargs, method reference and SAM conversion

Collin Fagan collin.fagan at
Tue Jan 11 05:01:07 PST 2011

Hi Remi,

Just to clarify, you would like varargs paramaters to be .. um, "flattened"
(unwound? de-vared?) when checking for compatible method signatures during
method reference assignment?

That sounds cool, would you think a method that has a vararg should also
compatible with methods that take none of the vararg type?

interface PrintOneString {
  void printOneString(String value);
PrintTwoStrings  pts = System.out#printf;


On Tue, Jan 11, 2011 at 4:48 AM, Rémi Forax <forax at> wrote:

>  There is no special support of varargs method reference.
> But it will be cool if the following code was legal.
> interface PrintTwoStrings {
>   void print2Strings(String format, String value);
> }
> PrintTwoStrings  pts = System.out#printf; // printf is declared
> Printf(String, Object...)
> pts.print2Strings("%s", "foo");
> It seems that JSR 292 will be able to support this feature without
> supplementary runtime cost.
> Rémi

More information about the lambda-dev mailing list