Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven: An illegal reflective access operation has occurred

Tags:

maven

At execution of any arbitrary mvn command I get following warnings at the beginning of the logs:

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.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$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 

Unfortunately, these warnings sometimes lead to errors at runtime and break my maven command execution. Does anyone know how to address this and get rid of these warnings?

My maven version:

Apache Maven 3.5.2 Maven home: /usr/share/maven Java version: 11.0.2, vendor: Azul Systems, Inc. Java home: /usr/lib/jvm/zulu-11-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.15.0-47-generic", arch: "amd64", family: "unix" 
like image 363
wero026 Avatar asked Apr 03 '19 10:04

wero026


People also ask

How do you avoid an illegal reflective access operation has occurred?

Avoid illegal reflective access You can specify the reflective access explicitly using java's –add-opens parameter. The migration guide for JDK 11 provides more information. Use a compatible and certified version of your software.

What is illegal reflective access operations?

The "an illegal reflective access operation has occurred" is merely a warning message and only indicating there is reflective access to JDK internal class without doing anything about it. In the meantime, you can either. You can specify the reflective access explicitly using java's --add-opens parameter.

How do I set illegal access to Java?

To verify that your application is ready for a future version of the JDK, run it with --illegal-access=deny along with any necessary --add-opens options. Any remaining illegal-access errors will most likely be due to static references from compiled code to JDK-internal APIs.


1 Answers

My best guess: your guice version is not compatible with Java 11.

like image 57
J Fabian Meier Avatar answered Sep 28 '22 11:09

J Fabian Meier