Adam Bien's Weblog

Thursday Apr 03, 2014

GlassFish v4.0.1 Daily Build Supports Java 8 Lambda

GlassFish v4.0 does not support lambdas. If you attempt to deploy a Java EE 7 application with CDI and Lambdas you are going to get the following exception:


Severe:   Exception while visiting WEB-INF/classes/com/airhacks/lambda/test/BackendService.class of size 1825
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)

The following test source was used:


@RequestScoped
public class BackendService {

    public double average() {
        List<Integer> numbers = new ArrayList<>();
        numbers.add(42);
        numbers.add(21);
        numbers.add(7);
        return numbers.stream().mapToInt(i -> i).average().getAsDouble();

    }
}

However, GlassFish v4.0.1 nightly builds builds starting with March, 20th 2014 supports Java 8 and lambdas. You can deploy Java EE 7 applications running on Java 8 with lambdas.

See you at Java EE Workshops at MUC Airport!


Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014

A book about rethinking Java EE Patterns

Comments:

Cool. Any idea on how to get support on 4.0? Anything that I can upgrade or patch myself?

Posted by Yannick Majoros on April 18, 2014 at 04:05 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
...the last 150 posts
...the last 10 comments
Links
License