differences between lambda binary vs. JSR 335 EDR (updated)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Feb 7 03:37:12 PST 2012
Hi,
Here's a list of the remaining outstanding differences between the
compiler implementation (binary snapshot) and the spec EDR:
*) 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)->{};
*) 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
}
With respect to the previous binary snapshot, the following changes have
been integrated:
*) added support for inlined syntax for extension methods
i.e.
void m() default { ... }
instead of:
void m() default Foo.m
*) added support for '::' for method references:
i.e.
SAM s1 = foo::bar;
SAM s2 = Foo<String>::new;
SAM s3 = new Bar()::<Z>baz;
*) new parser scheme for lambda expressions - now mix of
explicit/implicit parameters is not accepted (as per EDR)
i.e.
SAM s1 = (int x1, x2)->x1 + x2; //error
*) new parser scheme for method references - now explicit argument types
on method references are not accepted (as per EDR)
i.e.
SAM s1 = foo::bar(String); //error
SAM s2 = foo::new(Integer, List<String>); //error
*) added support for target-typing in conditional expressions
i.e.
SAM s = cond ? ()->true : ()->false;
Maurizio
More information about the lambda-dev
mailing list