Klitos Kyriacou

04/29/2022, 12:16 PM
Hello, the code in the thread gives a warning. Is this intended behaviour or am I abusing Mockk?
Minimal example 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 {
    fun test() {
        val threadPoolExecutor = mockk<ThreadPoolExecutor>() {
            every { corePoolSize } returns 3
Running this test results in:
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(
Is this related to or a separate issue?


04/29/2022, 4:09 PM
I think it's more likely related to