Describe the bug
Several illegal reflective access warnings occur when running tests with a JDK 11.
Steps to reproduce
Just run ./gradlew build with JDK 11 or higher. Or you can also just run ./gradlew :opentelemetry-sdk:test.
What did you expect to see?
No warnings or errors 馃槂
What did you see instead?
See this output snippet:
> Task :opentelemetry-sdk:test
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.junit.contrib.java.lang.system.EnvironmentVariables (file:/C:/Users/.../.gradle/caches/modules-2/files-2.1/com.github.stefanbirkner/system-rules/1.19.0/d541c9a1cff0dda32e2436c74562e2e4aa6c88cd/system-rules-1.19.0.jar) to field java.util.Collections$UnmodifiableMap.m
WARNING: Please consider reporting this to the maintainers of org.junit.contrib.java.lang.system.EnvironmentVariables
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
I'm pretty sure these come from https://github.com/open-telemetry/opentelemetry-java/blob/v0.6.0/sdk/src/test/java/io/opentelemetry/sdk/common/export/ConfigBuilderTest.java#L271-L273
What version and what artifacts are you using?
Artifacts: None, I'm building from source.
Version: Master @ 8005c7eddd456b91023c661e8e9a9e37f641c9bb
How did you reference these artifacts? Cloning the repository.
Environment
Compiler: openjdk version "11.0.3" 2019-04-16 (AdoptOpenJDK)
OS: Windows 10
Seems like a junit4 helper. I'm happy to solve it as part of https://github.com/open-telemetry/opentelemetry-java/issues/1452 if anyone gives it a nod of support :)
@anuraaga Migrate to JUnit5 is a good option.
Yeah, since #1187 this is possible.
@Oberon00 Migrated to JUnit5 but unfortunately the new module uses the same approach for setting environment variables which mutates an unmodifiable map's private method. I guess it's important to have the test, so fixing this would require separating out a test source set / gradle test task for it I think. It's a lot of complexity but do you think it's worth it? Will do if so :)
You could test everything but the System.getEnvironment since there is already a method taking a string map. I think Java 11 also has a process package so there may be a public API for that now.
Hmm, I think there are also command line options you could pass to the JVM (configured in gradle) to explicitly allow the access.
Yup will take a look.
@anuraaga should I assign this to you?
Sure, but I don't think this is required for ga. It's a small point about the tests. And compared to the instrumentation repo where Groovy spams this seems pretty minor.