I attended a talk at JavaOne 2013 on Expression Language 3.0. It was a great talk by Ed Burns and Kin-man Chung about EL. EL 3.0 has been modular for a while, and can operate independently of the EE platform. I knew that, but this was a siren call reminder of that fact. During the talk, I asked a number of questions and for clarifications. One interesting clarification was that EL 3.0 was compiled using Java 7. This was following a discussion of the fact that it supports Lambda expressions. Wait... it uses Lambda expressions from Java 8 and is compiled using Java 7. I asked could it be compiled on Java 6. Kin-man Chung, the specification lead, told me that with some minor changes; "it should?" I took that as a challenge to try. I was successful and now I can do Lambda expressions on JDK 6.
When I mentioned that I was using this technique for Java 6 on Twitter, Michael Graciano pointed out that +Adam Bien had done something similar for Java 1.7. I am not sure if great minds think alike, or fools seldom differ on this one, but his article is a very cool read too.
@jyeary @RichardWarburto you mean something like this? http://t.co/CdaR29wJBw
— Michel Graciano (@mgraciano) October 2, 2013
Technical DetailsThe easiest way to try it out for yourself is to download the compiled version here: javax.el-3.0.0-custom.jar
If you want to create your own, then follow these easy steps.
- Download and install Java CC 6.0
- Download Java EL project using NetBeans Team Server on Java.net, or using Subversion: https://svn.java.net/svn/el-spec~source-code/tags/javax.el-3.0.0
- Open the impl directory and modify the build.xml file to point to your Java CC 6.0 directory, for example:
- Change the pom.xml to source and target level 1.6
- Change the version in the pom.xml so that it is distinguishable from the RI.
- Execute a mvn clean
- In the impl directory, execute ant. This will compile the parser code for EL.
Note: This is a very important step!
- Modify the org.glassfish.el.test.ELProcessorTest, and remove all of the try with multicatch, and diamond operators.
- Execute mvn clean install.
If you were successful, you will have a version of EL 3.0 that will run on Java SE 6.
You can test your code using some of the examples found in the references below, or using the sample code snippet that uses some of the code from the references.