system-lambda icon indicating copy to clipboard operation
system-lambda copied to clipboard

illegal reflective access operation

Open cemeyer2 opened this issue 5 years ago • 3 comments

Running a test suite that leverages WithEnvironmentVariables in a docker container based on openjdk:11-jdk, I get the following warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.github.stefanbirkner.systemlambda.SystemLambda$WithEnvironmentVariables (file:/root/.gradle/caches/modules-2/files-2.1/com.github.stefanbirkner/system-lambda/1.1.0/488b3059b67701b821355dafd952c0c7110f7ba9/system-lambda-1.1.0.jar) to field java.util.Collections$UnmodifiableMap.m
WARNING: Please consider reporting this to the maintainers of com.github.stefanbirkner.systemlambda.SystemLambda$WithEnvironmentVariables
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

The code executes fine, but the warning is slightly concerning if in fact a future release of the JVM will break this library. Is there something I can do in my code to not cause the illegal access?

Thanks!

cemeyer2 avatar Oct 08 '20 21:10 cemeyer2

Unfortunately not. You're right. The code may break in a future JVM because the environment variables support relies on internal details. AFAIK there es no other way apart from mocking the System class.

stefanbirkner avatar Oct 08 '20 21:10 stefanbirkner

#31 has a log of where that issue begins in the tests

FreedomFaighter avatar Oct 16 '23 21:10 FreedomFaighter

https://www.baeldung.com/java-unit-testing-environment-variables#3-when-reflective-access-doesnt-work

ashleyfrieze avatar Oct 24 '23 06:10 ashleyfrieze