JDK 8 inclusion plan ?

Rémi Forax forax at univ-mlv.fr
Tue Jul 26 07:29:31 PDT 2011


On 07/26/2011 08:35 AM, Martin Skurla wrote:
> Hi,
>
>
> JDK 7 will be soon released and we there will be preparation for JDK 8
> soon. I want to ask if type annotations will be part of JDK 8, if
> there is official state from Oracle.
>
> The question is if the type system after adding lambda expressions/
> closures + type annotations will not be way too complex to understand.
>
> And I want to ask if you support or plan to support type annotations
> within lambdas?
>
>
> Bye,
> M.

CC to lambda-dev list, I may be wrong.

Lambda spec adds new syntax but no new kind of type,
a lambda is converted to be seen as an instance of an interface
with one method.

Runnable r = #{ System.out.println("hello lambda"); };

You can see it as a better inner class, a better classless inner class
is in fact a more accurate picture.

Because the lambda spec use interfaces to type lambdas
there is no new kind of type for JSR 308.

I see only one interaction between JSR335 and JSR308,
JSR308 allows you to specify annotation on return type
but the lambda syntax doesn't specify any return type
(the return type is inferred from the return type of the method
of the interface).

Comparator<String> c = #{ s1, s2 -> Integer.compare(s1.hashCode(), 
s2.hashCode()) };

Here, the return type of the lambda is int because the method compare of 
Comparator
returns an int. The open question is how to specify a type annotation of 
this
implicit return type ?

So to answer to your question, introducing lambdas as it's currently 
specified doesn't
change the type system (still only use nominal types, no structural type)
but lambda spec introduces a new syntax that will require JSR308 to specify
where to put the type annotation corresponding to the implicit return type.

cheers,
Rémi




More information about the lambda-dev mailing list