https://kotlinlang.org logo
Title
k

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 {
    @Test
    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(Reflection.java:392)
Is this related to https://github.com/mockk/mockk/issues/565 or a separate issue?
e

ephemient

04/29/2022, 4:09 PM
I think it's more likely related to https://github.com/mockk/mockk/issues/616