Groovy supported invokedynamic (indy) in version 2.0 beta 3 that was released on May 7. This is a short post just to show you how to restart your Groovy life with indy. Indy is a new bytecode instruction of Java SE 7 for dynamic method invocation. If you don't know about indy, read its JSR.
Okay, let's start. First of all, install an indy-supported version of Groovy. Because indy is not supported by default for now (2.0 beta 3). You can choose which of the following ways:
* Download an archive and use a groovy-indy.jar or groovy-all-indy.jar in indy/ instead of groovy.jar in lib/ or groovy-all.jar in embeddable/.
* Build from source with an option to enable indy.
ant install -DuseIndy=true -DskipTests=true
Second, compile with an option to enable indy in a way that meets your needs as follows:
groovy --indy YourScript.groovy
groovyc --indy YourScript.groovy
* GroovyShell class
import org.codehaus.groovy.control.CompilerConfiguration def conf = new CompilerConfiguration() conf.optimizationOptions.indy = true def shell = new GroovyShell(conf) shell.evaluate(/* your script */)
That's all! Have a nice Groovy life!