WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$2

Viewed 1656

I'm getting an warning message when running my webapp on Tomcat 9 server using java 11.

Errors follows:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$2 (file:/C:/Users/<myuser>/Documents/Workspace2019-09/.metadata/.plugins/org.eclipse.wst.server.core/tmp8/wtpwebapps/myproject/WEB-INF/lib/guice-3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$2
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

I google it for this particular error, and found that adding the following to the VM arguments will resolve the warning.

--add-opens java.base/java.lang=ALL-UNNAMED

Is there an alternative to resolve this kind of error? Some suggest to debug it with the following. Who's responsible for maintaining com.google.inject.internal.cglib.core? How soon guice 3.0 won't be supported ?

--illegal-access=deny

The warning itself says to use the following:

--illegal-access=warn

Here are my libraries:Web Libraries

2 Answers

This a known bug. It's being fixed in version 5 of Guice, which is to be released soon (probably). Just wait for version 5 to be released and then upgrade for it. My current build of Guice, based on the master branch doesn't have this issue anymore.

If you're not afraid of beta versions, you can use Guice 5.0.0-BETA-1 which fixes the issue everywhere except in assisted injection. The full fix is already ready, but a new beta build with that fix for assisted injection has not been released yet.

Related