SystemEnvironmentTestListener - Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible:
See original GitHub issueWhich version of Kotest are you using KoTest - 5.3
Kotlin - 1.6.20
I’m getting the following error when trying to run this code line in a WordSpec test.
class PublisherServiceTest : WordSpec() {
private val pubSubService = install(TestContainerExtension(pubSubContainer)) {
addExposedPort(8085)
}
private val address: String = "${pubSubService.host}:${pubSubService.firstMappedPort}"
override fun listeners() = listOf(SystemEnvironmentTestListener("PUBSUB_TARGET", address)) //<<< FAILING HERE
init {
...
}
}
Error Message:
Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @309e345f
This is directly thrown when in SystemEnviromentExtensions.kt line 99 is called:
classOfMap.getDeclaredField("m").asAccessible().get(systemEnv) as MutableMap<String, String>
method: getEditableMapOfVariables
@Suppress("UNCHECKED_CAST")
private fun getEditableMapOfVariables(): MutableMap<String, String> {
val systemEnv = System.getenv()
val classOfMap = systemEnv::class.java
return classOfMap.getDeclaredField("m").asAccessible().get(systemEnv) as MutableMap<String, String>
}
Is there something I’m doing wrong?
Issue Analytics
- State:
- Created a year ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
Unable to make field private final java.util ... - Stack Overflow
I solved my problem. Turns out the JRE that eclipse had automatically downloaded and was using wasn't compatible with this version of ...
Read more >Fix 'Unable make field private final java.util ... - YouTube
Cucumber #Selenium #Appium #RestAssured #Automation#Error message #ExceptionInInitializerError # java. util.
Read more >Example usage for java.lang.reflect Field setAccessible
In this page you can find the example usage for java.lang.reflect Field ... setAccessible(true); Object obj = field.get(env); Map<String, String> map ...
Read more >Java 16 error in "HTreeMap.put()": Unable to make field final java.util ...
Hi,. I switched to Java 16 today, and the put() below produces an error. It works with Java 15. My code is compiled...
Read more >unable to make field private final java.time ... - You.com
LocalDate java.time.LocalDateTime.date accessible: module java.base does not "opens java.time" to unnamed module @27abe2cd'} java.lang.reflect ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added info here on how you can work around it: https://kotest.io/docs/extensions/system_extensions.html (see the blue info box)
@sksamuel I first raised #3112 which brought me here.
So I edited
gradle.properties
I had a first issue
Overriding a variable when mode is set to SetOrError. Use another OverrideMode to allow this. Trying to set {FIXED_OTP=hi42}
That’s not a bug per se, but the fix was not obvious, it would be nice to mention it in the documentation https://kotest.io/docs/extensions/system_extensions.html
Alas that still fails
java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @47089e5f
https://scans.gradle.com/s/rqvdpgm2f5fq6/tests/:test/com.tignum.backend.core.health.SanityCheckerTest/fixed OneTimePassword can be enabled only in the local environment()?expanded-stacktrace=WyIwIl0&top-execution=1