title: Java 8 Lambda Expression Within REST Service not working
body: <p>If I put a Java 8 Lambda expression in a REST service, it crashes. If I remove the lambda expression, it works.  It does not matter if I use the lambda expression or not. Just the existence the lambda is enough to crash. Everything else Java 8 related seems to work.</p>
  
  <p>Below is my code (simplified):</p>
  
  <pre><code>@Path("finance")
  public class FinanceRest {
  
      @GET
      @Produces("text/plain")
      public String speak() {
          return "Hello world.";
      }
  
      private void lambdaFunction(Predicate&lt;Account&gt; predicate) {
          // Any lambda will cause problems, no matter how simple
          List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
          Stream&lt;Integer&gt; onlyOdds = numbers.stream().filter(n -&gt; n%2 != 0);
      }
  
  }
  </code></pre>
  
  <p>As you can see from the code above, just the existence of a lambda expression will cause failure.  As soon as I remove the lambda, it works fine. The other Java 8 stuff is fine (for example, the "Predicate" input parameter).</p>
  
  <p>The error message I'm getting is:
  <strong>java.lang.ArrayIndexOutOfBoundsException: 25980</strong></p>
  
  <p>I've tried this on Tomcat 7 and 8 using Java 8.
  I'm using the standard jax-rs stuff from JavaEE 6.... in other words my POM file has this:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
          &lt;version&gt;6.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>Any help would be appreciated.
  Thanks.</p>
  
  <p>The exact error message (on Glassfish 4.0... I've tried both Tomcat and Glassfish) is:</p>
  
  <blockquote>
    <p>java.lang.ArrayIndexOutOfBoundsException: 52264   at
    org.objectweb.asm.ClassReader.readClass(ClassReader.java:2015)    at
    org.objectweb.asm.ClassReader.accept(ClassReader.java:469)    at
    org.objectweb.asm.ClassReader.accept(ClassReader.java:425)    at
    org.glassfish.hk2.classmodel.reflect.Parser$5.on(Parser.java:362)     at
    com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.handleEntry(ReadableArchiveScannerAdapter.java:165)
      at
    com.sun.enterprise.v3.server.ReadableArchiveScannerAdapter.onSelectedEntries(ReadableArchiveScannerAdapter.java:127)
      at org.glassfish.hk2.classmodel.reflect.Parser.doJob(Parser.java:347)
      at
    org.glassfish.hk2.classmodel.reflect.Parser.access$300(Parser.java:67)
      at
    org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:306)
      at
    org.glassfish.hk2.classmodel.reflect.Parser$3.call(Parser.java:295)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)     at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:744)</p>
  </blockquote>