The improvement introduced on Groovy 2.0 is the support for the invoke dynamic instruction.[New instructions are available in java-7.] . Groovy already had a windows installation.In this post we will look how to install groovy in Linux machines. This post also talks about How to use indy command,groovy installation path linux,install groovy sdk linux.
Dynamic languages generate bytecode by invoking a lot of methods to perform a single operation. In this way, reflection and dynamic proxies are very costly operations.They are used extensively too. Even JIT(Just In Time) compiler can not help to improve the runtime performance of the JVM. It is due to the fact that runtime performance of JVM depends on information and pattern.
All the new invoke dynamic partially mitigate these issues hence it produces better JIT optimization. Invoke dynamics is also known as indy.runs on Groovy and Java-7.
Now can a developer use it?
No,indy is purely compile time and runtime feature.So no developer can use it from source code. This is same like garbage collection coding in Java.Developer has very little or no control of indy(that is runtime performance).
How to invoke the groovy with invoke dynamic? or how to leverage invokedynamic instruction?
groovy installation path linux
- Check the java version,Indy works post Java-1.7. So in command prompt type java-version. It will produce Java version “1.7.0_XX”.
- Go to groovy home directory and make a separate folder called “old”.
- Move all the jars that starts with groovy[in the lib directory] to old folder.
- Go to root directory of groovy and find indy folder.
- Copy all the jars from it to groovy home directory.
- Rename the jar files in such a way that -indy classifier should not be a part of the name.
- Now compile your Groovy code with –indy flag.
How to use indy command?how to install groovy sdk linux
Note: if — indy flag is omitted then indy will not be invoked and it will be regular Groovy execution even if we have change the libs.
The operation is similar to the assert operation in Java.