Details
Description
Now that Java 6 released, there's a lot of interest going around about the new JSR 223 scripting platform. Unfortunately, neither Java SE 6 nor the current Groovy builds support JSR 223-style Groovy out of the box.
Fortunately, adding this to Groovy is trivial. The code is both simple and available from the JSR 223 reference implementation (https://scripting.dev.java.net/). The license permits redistributing as source or binary as long as mention that some code comes from Sun and release them from liability.
Ideally, the Groovy project should integrate the three implementation classes and the service declaration into groovy-1.0.jar. If you do this, simply dropping Groovy into your classpath is enough to enable the Groovy engine. At the very least, we should bundle the RI's groovy-engine.jar into the groovy binary distribution. Finding and installing the Sun RI is a bit of a pain and will discourage would-be users.
Behind the scenes, scripting engines get enabled by adding a file to the META-INF/services directory of a JAR as specified in the new Java 6 java.util.ServiceLoader (http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html). This file just tells the JVM that it can find a service implementation in a specific class. For JSR 223, the implementation is just a concrete ScriptEngineFactory and a couple of support classes:
I'm happy to volunteer any assistance that might help make this part of the Groovy distribution. However, adding these classes and the service definition to groovy-1.0.jar should be trivial and will provide a great service (pun intended).
Hi Andy!
JSR 223 is largely irrelevant to Groovy.
JSR 223 is really about trying to map language constructs from some arbitrary scripting language onto Java. So, basically it's a way of making a language which is Java unaware able to interact with Java code. It's like JNI in that respect (and about as beautiful!)
Groovy is Java aware. We have spent all our time in reducing the impedance between Groovy and Java to zero. We really do not want to encourage the misapprehension that it requires some bit of plumbing to interface Groovy with Java. So My view is that we distance ourselves from JSR 223 and in no way encourage people to use it with Groovy.