Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy - WARNING: An illegal reflective access operation has occurred

Tags:

java

groovy

I am pretty much new to java and groovy. I have installed groovy 3.0 on my windows 10 laptop (64 bit) and when tried to run groovy getting following warning:

>groovy -v
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/groovy-3.0.0-alpha-1/lib/groovy-3.0.0-alpha-1.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-1 JVM: 9.0.1 Vendor: Oracle Corporation OS: Windows 10

And the java version is:

java --version
java 9.0.1
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

Any help to resolve this.

like image 460
Here_2_learn Avatar asked Dec 22 '17 04:12

Here_2_learn


3 Answers

To disable the warnings you can pass --add-opens to the JVM, see details here. Unfortunately Groovy requires a lot of modules/packages to be opened, see this (currently reverted) commit (source). Just tested these with AdoptOpenJDK 11.

like image 88
crusy Avatar answered Nov 03 '22 21:11

crusy


It is more than a 'warning' for me: I cannot get Groovy scripts to run (on macOS) with the current JVM 9, much less 10. The workaround (until a compatible version of Groovy is available) is to install jenv and an earlier version of Java, so you can switch when needed.

like image 7
T Semple Avatar answered Nov 03 '22 22:11

T Semple


Although my environment is Linux, after struggling some days to setup Groovy on Grails environment I feel like I know the answer: use JDK 8 for now. I was fiddling with JDK 9, and I thought it was too far behind so I tried JDK 11, which made things even worse, I got actual crashes. It seems like that Groovy / Grails is heavily lagging behind in terms of Java version compatibility.

Once the new Groovy will be released (said to be end of this year) then newer JDK can be used as well.

like image 4
Csaba Toth Avatar answered Nov 03 '22 20:11

Csaba Toth