title: Why does lambda translation need generation of a static method?
body: <p>Lambda translation is a two step process, <strong>One</strong>: desugaring the lambda into a static method in same class.</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          Runnable r = () -&gt; System.out.println("Hello");
          System.out.println(Arrays.asList(Main.class.getDeclaredMethods()));
      }
  }
  </code></pre>
  
  <blockquote>
    <p>[<strong>private static void Main.lambda$main$0()</strong>, public static void
    Main.main(java.lang.String[])]</p>
  </blockquote>
  
  <p><strong>Two</strong>: generation of a class that implements the Functional Interface.</p>
  
  <pre><code>System.out.println("A class has been generated: " + r.getClass());
  System.out.println("That implements a Functional Interface: " + Arrays.asList(r.getClass().getInterfaces()));
  </code></pre>
  
  <blockquote>
    <p>A class has been generated: class Main$$Lambda$1/149928006 </p>
    
    <p>That implements a Functional Interface: [interface java.lang.Runnable]</p>
  </blockquote>
  
  <p><strong>Question</strong>: <strong>What is the need of this static method?</strong> Why can't the lambda body be put directly into the interface method? Something like: </p>
  
  <pre><code>class Main$$Lambda$1 {
      public void run() {
          /* Lambda body here */
      }
  }
  </code></pre>