lambda/lambda/langtools: initial lambda push; the current prototype suuports the following features:

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri May 28 08:04:51 PDT 2010


On 28/05/10 15:40, Rémi Forax wrote:
> I've found some bugs :)
>
> // this doesn't compile - how to declare a function type that doesn't 
> takes any parameter ?
> #int() bar;

I'm in the process of fixing this...
>
>
> // in my opinion, an instruction can start with a lambda that has a body,
> // but the hand-coded grammar of the compiler doesn't allow that.
> #(int x) { System.out.println(x); }.();
>
> // Open question: can an instruction starts with a lambda expression ?
Good question; my choice has been to make lambda a plain expression, 
rather than an expression statement; this way it is mandatory to always 
wrap a lambda either within a function type or within a SAM type.
>
>
> // this snippet generate invalid code (at bytecode offset 4)
> int v = #(Object o) {
>   System.out.println(this.type());
>   return 3;
> }.("foo");

the .type() syntax is not supported yet, hence the bad bytecode.

Thanks for the headsup!

Maurizio

>
> static int lambda$0(java.dyn.MethodHandle, java.lang.Object);
>     Code:
>        0: getstatic     #1          // Field 
> java/lang/System.out:Ljava/io/PrintStream;
>        3: aload_0
>        4: invokevirtual #2       // Method 
> "".type:()Ljava/dyn/MethodType;
>        7: invokevirtual #3       // Method 
> java/io/PrintStream.println:(Ljava/lang/Object;)V
>       10: iconst_3
>       11: ireturn
>
>
> Rémi
>



More information about the lambda-dev mailing list