Reputation: 23006
Same issue as Groovy - WARNING: An illegal reflective access operation has occurred, just that
--add-opens
to the JVM), I'm not able to make it working for me.$ groovy -version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/groovy/lib/groovy-2.4.21.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: 2.4.21 JVM: 11.0.12 Vendor: Ubuntu OS: Linux
$ java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-Ubuntu-0ubuntu3)
OpenJDK 64-Bit Server VM (build 11.0.12+7-Ubuntu-0ubuntu3, mixed mode, sharing)
$ java --add-opens java.base/java.lang=ALL-UNNAMED -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-Ubuntu-0ubuntu3)
OpenJDK 64-Bit Server VM (build 11.0.12+7-Ubuntu-0ubuntu3, mixed mode, sharing)
$ groovy --add-opens java.base/java.lang=ALL-UNNAMED -version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/groovy/lib/groovy-2.4.21.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
Caught: java.io.FileNotFoundException: /export/home/me/--add-opens (/export/home/me/--add-opens)
java.io.FileNotFoundException: /export/home/me/--add-opens (/export/home/me/--add-opens)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
$ apt-cache policy groovy
groovy:
Installed: 2.4.21-1
Candidate: 2.4.21-1
Version table:
*** 2.4.21-1 500
500 http://archive.ubuntu.com/ubuntu impish/universe amd64 Packages
500 http://archive.ubuntu.com/ubuntu impish/universe i386 Packages
100 /var/lib/dpkg/status
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish
Update, I've tried to set JAVA_OPTS
as well:
export JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED"
$ groovy -version
Unrecognized option: --add-opens
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
How to get rid of that warning message?
Upvotes: 1
Views: 5560
Reputation: 11
Follow the instructions here: https://groovy-lang.org/install.html This will:
Worked for me on:
Upvotes: 1
Reputation: 4380
It's clear from the FileNotFound exception that the --add-opens was not used as a JVM flag. Have you tried setting JAVA_OPTS? Like so:
export JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED"
groovy --version
I don't get the same error as you. I actually still get the reflective access warnings, not an error about --add-opens
being unrecognized.
Even with --illegal-access=permit
I still see the warnings. Odd. I'm sure the JAVA_OPTS value is being used as it does complain if I set it to an invalid flag.
Do you have JAVA_HOME defined? I noticed groovy also picks up that value to choose the JVM.
With Java 17 I get no warnings or errors.
Upvotes: 0