I'm facing a future problem that I have to solve right now and the problem is a class from a library I do not own (Jackson) that is accessing through reflection to another. To be more specific, this is the warning that I'm trying to solve:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.fasterxml.jackson.module.afterburner.util.MyClassLoader (file:/Users/pedro.maria/.m2/repository/com/fasterxml/jackson/module/jackson-module-afterburner/2.13.4/jackson-module-afterburner-2.13.4.jar) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.module.afterburner.util.MyClassLoader
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
Now, the most frustrating part is that I'm staring the solution in the face, the --add-opens
flag that needs to be passed to the JVM in order for it to know that this reflection is intended. For some reason I'm not being able to figure out a couple of things which are:
-
Where should this flag be passed? (Through
MAVEN_OPTS
, as a Maven argument such as-DargLine
, in the Dockerfile, etc...) -
What should the --add-opens flag look like? (I've tried
--add-opens java.base/java.lang=ALL-UNNAMED
which doesn't make sense to me since I think I should be referencing the Jackson module which I can't find because the documentation is scattered everywhere and not helpful
These are the sources that I took a look at before coming here for help:
- Warning on Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil
- What is an illegal reflective access?
- https://www.baeldung.com/java-illegal-reflective-access
- https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-12F945EB-71D6-46AF-8C3D-D354FD0B1781
- JDK 11 migration issue from JDK8, Illegal reflective access by com.fasterxml.jackson.module.afterburner.util.MyClassLoader
PS: If the answers could include an explanation of how you formulated the --add-opens flag to properly solve the warning messages I would be very thankful because I've been trying to understand this for a while now but with no success.
Aucun commentaire:
Enregistrer un commentaire