vendredi 2 avril 2021

Unexpected exception for remote running unit tests with MethodHandles

The following line of code in tests

var lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup());

where Field is java.lang.reflect.Field throws a

java.lang.IllegalAccessException: module java.base does not open java.lang.reflect to unnamed module @497470ed
    at java.lang.invoke.MethodHandles.privateLookupIn(MethodHandles.java:260) ~[?:?] 

The code works fine if tests are run locally (either via IDE or maven lifecycle), but fails on maven test run on CI pipeline on a remote host.

Maven is configured for java 11, but test execution as we saw in logs was using openjdk-16 jvm.

Would appreciate any ideas on where to look.





Aucun commentaire:

Enregistrer un commentaire