1

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:

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Pmsmm
  • 352
  • 5
  • 17
  • 3
    Is your use-case specifically Jackson Afterburner? If so, consider replacing it with [Jackson Blackbird](https://github.com/FasterXML/jackson-modules-base/tree/master/blackbird) instead. It is intended as the replacement of Afterburner specifically for this problem. – Mark Rotteveel Sep 29 '22 at 16:59
  • 2
    Not everything called “module” is a module in sense of Java’s module system. “ALL-UNNAMED” refers to the unnamed modules covering everything loaded through the class path. – Holger Sep 30 '22 at 06:47
  • @MarkRotteveel I figured out the problem but there is not solution besides the --add-opens flag. This warning is issued when running the Dependency Check plugin and by the GitHub issue https://github.com/jeremylong/DependencyCheck/issues/2793 and taking a look at that issue the problem isn't yet solved. I will wait for a new release where this issue is solved but in the meanwhile I took note of the Blackbird library to solve future problems I might have due to this Afterburner dependency. Thank you so much Mark! – Pmsmm Sep 30 '22 at 16:12
  • @Holger thank you for that explanation, now I understand the ALL-UNNAMED reference. In the meanwhile a related question would be, if this refers to unnamed modules, that means that when modules are named they won't be "caught" by the ALL-UNNAMED, I would have to reference them individually by name correct? (Sorry if this might seem an unnecessary question) – Pmsmm Sep 30 '22 at 16:14
  • 2
    Well, since you have a problem with a software that has not been adapted to the module system, it normally wouldn’t become a named module. Unless you move it from the class path to the module path deliberately, which would turn it into an “automatic module”. Which most likely would make problems even worse. But generally, yes, the `--add-opens` option would have to name every name of a module that requires the access, individually. But modules should not require such an access. (Letting aside modules for testing and debugging). – Holger Sep 30 '22 at 16:20

0 Answers0