Groovy Invoke Dynamic Support

The release of Groovy 2.1 comes with full Invoke Dynamic Support. Initially I had issues with trying to get a working example up and running as seen by the following message.

> groovy –indy mergesort.groovy

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during class generation: Cannot use invokedynamic, indy module was excluded from this build.

I checked the groovy version to make sure that I had Java 7 loaded as seen here groovy -version Groovy Version: 2.1.0 JVM: 1.7.0_11 Vendor: Oracle Corporation OS: Mac OS X

In order to get things working, I read that I needed to get the “indy” jar on my classpath. I added the following to my .bash_profile and restarted my terminal and the error cleared up

export CLASSPATH=$HOME/.gvm/groovy/current/indy/groovy-2.1.0-indy.jar

Hope this helps and a huge thanks to the Groovy Core Team for this latest update!

-Juan