mardi 5 novembre 2019

InaccessibleObjectException after migrating from Java 8 to Java 11

I am migrating a rather large monolith spring boot application from Java 8 to Java 11. After i've fixed the removed JEE modules, i ran into several reflection errors based on the strong encapsulation by the new introduced module system concept.

Starting the application works with Java 11, however, performing a clean install via Maven doesnt work. There are several test failures caused by an InaccessibleObjectException due to reflection vs strong encapsulation.

java.lang.reflect.InaccessibleObjectException: Unable to make field private jdk.internal.reflect.MethodAccessorImpl jdk.internal.reflect.DelegatingMethodAccessorImpl.delegate accessible: module java.base does not "opens jdk.internal.reflect" to unnamed module @6a969fb8 at com......(some Test-Method).

I've already tried the solution suggested in that post How to solve InaccessibleObjectException ("Unable to make {member} accessible: module {A} does not 'opens {package}' to {B}") on Java 9?.

But neither using the parameter --add-opens java.base/jdk.internal.reflect=ALL-UNNAMED as Maven argument nor storing it in the maven jvm.config helps.

Are there any other approaches to get rid of these Exceptions?





Aucun commentaire:

Enregistrer un commentaire