-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemEnvironmentTestListener - Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: #3035
Comments
Which version of the jdk ?
…On Sun, Jun 5, 2022, 5:07 AM Marek00Malik ***@***.***> wrote:
*Which 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?
—
Reply to this email directly, view it on GitHub
<#3035>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFVSGTWOMU2CPJQJKDPJG3VNR355ANCNFSM5X42LMOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
java 17 |
Looks like this stopped working in Java16 and there's no way to set the map anymore. |
Can someone fix this? |
Can't fix the JVM. They've just removed the functionality.
We will prob need to just remove this from Kotest.
…On Mon, 6 Jun 2022 at 14:17, Marek00Malik ***@***.***> wrote:
Can someone fix this?
—
Reply to this email directly, view it on GitHub
<#3035 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFVSGSCMVRWXXJUN5VPCBDVNZFENANCNFSM5X42LMOA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
this is bad/sad news... :( How can we configure Ktor then after it already started with a container on a random port? |
From https://github.com/webcompere/system-stubs
|
They seem to still do it in some way, but bringing Mockito in. |
We do similar stuff with |
Just tested with And our code is still working. Can you help me reproduce, @Marek00Malik ? |
I added info here on how you can work around it: https://kotest.io/docs/extensions/system_extensions.html (see the blue info box) |
Thanks @Kantis, will test this later today! |
Closing, please reopen if issue persists. |
@sksamuel I first raised #3112 which brought me here. So I edited -org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4608M
+org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4608M --add-opens=java.base/java.util=ALL-UNNAMED I had a first issue That's not a bug per se, but the fix was not obvious, it would be nice to mention it in the documentation -withEnvironment(OtpSource.FIXED_OTP, "hi42", , OverrideMode.SetOrOverride) {
+withEnvironment(OtpSource.FIXED_OTP, "hi42") {
//
} Alas that still fails
|
For more background information see [1]. [1]: kotest/kotest#3035 Co-authored-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
For more background information see [1]. [1]: kotest/kotest#3035 Co-authored-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
For more background information see [1]. [1]: kotest/kotest#3035 Co-authored-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
same issue... |
For me, the only fix was to have the following in the
Adding the arguments to |
Thanks, I updated the docs. 29aac29 |
Which 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.
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:
method: getEditableMapOfVariables
Is there something I'm doing wrong?
The text was updated successfully, but these errors were encountered: