question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mockkStatic leads to "Illegal reflective access" warning

See original GitHub issue

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

No Warning when using mockStatic function

Steps to Reproduce

 @Test
    fun `mockkStatic generates a warning`() {
        mockkStatic(LocalDate::class)
        every { LocalDate.now() } returns LocalDate.parse("2021-04-16")

        Assertions.assertEquals(16, LocalDate.now().dayOfMonth)
    }

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • MockK version: 1.11.0
  • Kotlin version: 1.4.10
  • JDK version: 11
  • JUnit version: 1.5
  • Type of test: unit test

Failure Logs

[Test worker] DEBUG io.mockk.impl.recording.states.AnsweringState - Answering 2021-04-16 on class java.time.LocalDate.now() WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by io.mockk.proxy.jvm.advice.MethodCall (file:/home/wjhf5963/.gradle/caches/modules-2/files-2.1/io.mockk/mockk-agent-jvm/1.11.0/424bbf69d819f115f8f5df9e7a897f680a483310/mockk-agent-jvm-1.11.0.jar) to method java.time.LocalDate.create(int,int,int) WARNING: Please consider reporting this to the maintainers of io.mockk.proxy.jvm.advice.MethodCall WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
brianyinglingcommented, Aug 4, 2021

+1. I’m experiencing the exact same issue and I am also not using roboelectric or android.

0reactions
Raibazcommented, Sep 15, 2022

I don’t have bandwidth to work on this now, but I’d gladly review a PR about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mockkStatic leads to "Illegal reflective access" warning -
[x] I am running the latest version · [x] I checked the documentation and found no answer · [x] I checked to make...
Read more >
Java 9 Illegal Reflective Access Warning - Baeldung
Before Java 9, the Java Reflection API has a superpower: It could gain access to the non-public class members without limitation.
Read more >
What to do about "illegal reflective access" - Google Groups
WARNING: An illegal reflective access operation has occurred. WARNING: Illegal reflective access by org.mockito.internal.util.reflection.
Read more >
"illegal reflective access" under Java 9, 10, 11 - Shibboleth
1WARNING: An illegal reflective access operation has occurred 2WARNING: Illegal ... If access is denied during parsing due to the restriction of this ......
Read more >
Illegal reflective access by com.intellij.util.ReflectionUtil to ...
ReflectionUtil WARNING: Use --illegal-access=warn to enable warnings of further ... This issue also leads to the Kotlin compiler not working on the new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found