generated lambda names - lambda$null$0

Robert Field robert.field at oracle.com
Tue Oct 7 02:16:51 UTC 2014


No attempt was made to make the name user friendly or descriptive -- 
they were designed to be unique and for javac debugging purposes remain 
generally constant over small changes.

The "null" in the name is NOT a bug.

-Robert

On 10/06/14 18:19, Rafkind, Jon wrote:
> Tools that work with bytecode will inevitably come across the generated
> lambda method names, and I noticed that lambdas nested inside other
> lambdas have strange 'null' names in them.
>
> public class x{
>      interface T{
>          int g();
>      }
>
>      public void test(){
>          T t1 = () -> {
>              T t2 = () -> 2;
>              return 1;
>          };
>      }
> }
>
> The bytecode contains these two desugared lambda methods:
>
> .method synthetic static private lambda$test$1 : ()I
> .method synthetic static private lambda$null$0 : ()I
>
> Where lambda$test$1 is the 't1' lambda, and lambda$null$0 is the 't2'
> lambda. It's not the end of the world to have 'null' there, but since an
> attempt at putting some useful info there is made maybe something better
> than 'null' could be chosen.
>
> Tested on jdk8u20.
>
> BTW, javap cannot dissassemble/show any of the generated lambda code.
> Perhaps hiding the generated lambda name from the user is ok, but there
> is no way to see the method bodies. I was about to write my own
> dissassembler based on the ASM library, but I found this nice github
> project that works just fine: https://github.com/Storyyeller/Krakatau
>



More information about the lambda-dev mailing list