mardi 27 juillet 2021

Issues with a separate java dependency using reflection access deemed illegal in Java 16

I am trying to use some code from another java project that was originally compiled in Java 8. My current project is compiled with Java 16. I can compile the other java project in Java 16, with the --add-opens and --illegal-access=permit vm options as suggested here.

After including the compiled .jar into my project, and making a call to one of its functions, I receive an error related to reflection access that doesn't seem to be allowed in Java 16. This is the error I get (with some parts ):

Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field int java.util.regex.Matcher.<redacted> accessible: module java.base does not "opens java.util.regex" to unnamed module

The code from the other .jar that seems to cause this is here:

<redacted>.setAccessible(true);

I've added the following VM options when building but it doesn't seem to resolve the issue:

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --illegal-access=permit

How does one get around the issue of another java project using reflection deemed illegal in Java 16? Thanks





Aucun commentaire:

Enregistrer un commentaire