Search code examples
javagroovyjava-11groovyshellgroovy-console

groovysh is giving invocation target exception


I recently installed groovy.

C:\Users\Shivendra Gupta>groovy -v
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/D:/IT%20Softwares/groovy-3.0.0-alpha-4/lib/groovy-3.0.0-alpha-4.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Groovy Version: 3.0.0-alpha-4 JVM: 11.0.2 Vendor: Oracle Corporation OS: Windows 10

Now when i run the groovysh command i get the error:

enter image description here

Also, when groovyConsole is behaving in strange manner :-

enter image description here

I think illegal reflective access warning is may be due to compatibility issues with jdk 11. Does this means i will not be able to work with jdk 11 for groovy ?Has anyone faced similar issue? how do i resolve this ?

EDIT: I just installed java 9. I am getting exactly same error with groovysh and groovyConsole command and also getting same warning on runnung groovy -v command


Solution

  • This was due to compatibility issue between JDK9/11 with groovy,I resolved this by installing JDK 8.