Nick's Blog

Groovy error WARNING: An illegal reflective access operation has occurred

Today I installed groovy on my new laptop with JVM 12. I downloaded Java from the official website and install groovy via brew

brew install groovy

However, after the installation, I was getting the following error when I call the groovy version.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/usr/local/Cellar/groovy/2.5.7/libexec/lib/groovy-2.5.7.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
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

After a bit of search, I realised there is a PR on https://github.com/apache/groovy/pull/811/

Unfortunately, there is no fix at the moment, but the following workaround can ignore the error

export GROOVY_TURN_OFF_JAVA_WARNINGS=true