differences between lambda binary vs. JSR 335 EDR
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Nov 22 05:48:16 PST 2011
Hi,
Here's a list of the main differences between the compiler
implementation and the spec EDR:
*) Compiler uses infix '#' instead of '::' for method reference syntax
(15.28)
i.e.
SAM s1 = foo#bar;
SAM s2 = Foo<String>#new;
SAM s3 = new Bar()#<Z>baz;
*) Compiler allows optional explicit argument types on method references
(15.28)
i.e.
SAM s1 = foo#bar(String);
SAM s2 = foo#new(Integer, List<String>);
*) Compiler accepts a mix of explicit/implict types in lambda parameter
declaration (15.27)
SAM s1 = (int x1, x2)->x1 + x2;
*) Compiler supports a slightly less powerful analysis for detecting
effectively final variables that only applies to variables with an
initializer (4.12.4)
void m() {
int x;
x = 2;
SAM s = ()->x*2; //error
}
*) Generic lambdas are not supported/generic functional descriptors are
not supported (15.27 and 9.8)
interface SAM {
<X, Y extends X> void m(X x, Y y);
}
SAM s = <U, V extends U>(x,y)->{};
*) Target-typing for conditional expressions is not supported (15.25)
SAM s = cond ? ()->true : ()->false; //error
Maurizio
More information about the lambda-dev
mailing list