title: Bad type on operand stack ... using jdk 8, lambdas with anonymous inner classes fails, why?
body: <p>Running the code below results in the error message <code>Bad type on operand stack</code>.</p>
  
  <pre><code>public static void main(String args[]) {
          TransformService transformService = (inputs) -&gt; {
              return new ArrayList&lt;String&gt;(3) {{
                  add("one");
                  add("two");
                  add("three");
              }};
          };
  
          Collection&lt;Integer&gt; inputs = new HashSet&lt;Integer&gt;(2) {{
              add(5);
              add(7);
          }};
          Collection&lt;String&gt; results = transformService.transform(inputs);
          System.out.println(results.size());
      }
  
      public interface TransformService {
          Collection&lt;String&gt; transform(Collection&lt;Integer&gt; inputs);
      }
  </code></pre>
  
  <p>However removing the double brace initialization (anonymous inner classes) within the lamda allows the code to run as expected, why ? The below works :</p>
  
  <pre><code>public class SecondLambda {
      public static void main(String args[]) {
          TransformService transformService = (inputs) -&gt; {
              Collection&lt;String&gt; results = new ArrayList&lt;String&gt;(3);
              results.add("one");
              results.add("two");
              results.add("three");
  
              return results;
          };
  
          Collection&lt;Integer&gt; inputs = new HashSet&lt;Integer&gt;(2) {{
              add(5);
              add(7);
          }};
          Collection&lt;String&gt; results = transformService.transform(inputs);
          System.out.println(results.size());
      }
  
      public interface TransformService {
          Collection&lt;String&gt; transform(Collection&lt;Integer&gt; inputs);
      }
  }
  </code></pre>
  
  <p>Compiler bug ? It is the early access version after all ...</p>
  
  <p>(This won't compile unless you have the latest <a href="http://jdk8.java.net/lambda/" rel="nofollow noreferrer">jdk 8 lambda download</a>.)</p>