Hello, the code in the thread gives a warning. Is this intended behaviour or am I abusing Mockk?
k
Hello, the code in the thread gives a warning. Is this intended behaviour or am I abusing Mockk?
Minimal example code:
Copy code
package org.example

import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.api.Test
import java.util.concurrent.ThreadPoolExecutor

class DemoTest {
    @Test
    fun test() {
        val threadPoolExecutor = mockk<ThreadPoolExecutor>() {
            every { corePoolSize } returns 3
        }
    }
}
Running this test results in:
Copy code
Apr 29, 2022 1:12:39 PM io.mockk.impl.log.JULLogger warn
WARNING: Failed to set backing field (skipping)
java.lang.IllegalAccessException: class io.mockk.InternalPlatformDsl cannot access a member of class java.util.concurrent.ThreadPoolExecutor (in module java.base) with modifiers "private volatile"
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392)
Is this related to https://github.com/mockk/mockk/issues/565 or a separate issue?
e
I think it's more likely related to https://github.com/mockk/mockk/issues/616
313 Views