title: How Lambda Expressions Are Translate In Java Byte Code
body: <p>I am trying to create an example using lambda expression in java and i am using offical JDK8. My example was run successfully. But when i trying to check how the compiler translate lambda expression into byte code, this makes me some confusion.Following is the code of my example:- </p>
  
  <pre><code>public class LambdaTest {
      public Integer lambdaBinaryOpertor(BinaryOperator&lt;Integer&gt; binaryOperator) {
          return binaryOperator.apply(60, 72);
      }
  
      public static void main(String[] args) {
          LambdaTest test = new LambdaTest();
          BinaryOperator&lt;Integer&gt; binaryOperator = (a, b) -&gt; a*b;
          System.out.println("Additon using Lambda BinaryOperator: "+test.lambdaBinaryOpertor(binaryOperator));
      }
  }
  </code></pre>
  
  <p>In this <a href="http://cr.openjdk.java.net/~briangoetz/lambda/lambda-translation.html">Article</a>, they discuss about how compiler translate the lambda expressions into byte code. According to this document the lambda expression convert into <code>static</code> method and the location where lambda expression declare, have reference of lambda <code>static</code> method. The following example is in the article : </p>
  
  <pre><code>//Source code
  class A {
      public void foo() {
          List&lt;String&gt; list = ...
          list.forEach( s -&gt; { System.out.println(s); } );
      }
  } 
  
  //After compile above code "translate code " 
  class A {
      public void foo() {
          List&lt;String&gt; list = ...
          list.forEach( [lambda for lambda$1 as Block] );
      }
  
      static void lambda$1(String s) {
          System.out.println(s);
      }
  }
  </code></pre>
  
  <p>My example run fine and give us the appropriate result. But when i trying to run the <code>javap</code> command for check the byte code of class, there is no static method for lambdas in byte code. </p>
  
  <pre><code>c:\&gt;javap LambdaTest
  Compiled from "LambdaTest.java"
  public class LambdaTest {
  public LambdaTest();
  public java.lang.Integer lambdaBinaryOpertor(java.util.function.BinaryOperator &lt;java.lang.Integer&gt;);
  public static void main(java.lang.String[]);
  }
  </code></pre>
  
  <p>In the case of generics, bridge method is created by compiler and we will also check this method using <code>javap</code> command, but in the case of lambdas there is no <code>static</code> method. The article was published at 2012 and java 8 was launch at march 2014. So i have some queries regarding transnational of lambda: </p>
  
  <ol>
  <li>Is there any new implementation used for lambda in JDK 8 after this article release or i will do something wrong to check the lambda method ?</li>
  <li>How really the compiler deal with lambda expression?</li>
  <li>How the JVM invoke the lambda exression ? </li>
  </ol>