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.

1.10.3 not working with Kotlin 1.3.72

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

Upgrading from 1.10.2 to 1.10.3 should not break existing code.

Current Behavior

Code does not execute anymore due to reflective use of Kotlin 1.4 API.

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. run the provided with version 1.10.2
  2. update to version 1.10.3
  3. run

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.10.3
  • OS: Linux
  • Kotlin version: 1.3.72
  • JDK version: 11.0.8
  • JUnit version: 5.7.0
  • Type of test: unit test

Stack trace

// -----------------------[ YOUR STACK STARTS HERE ] -----------------------
'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Object, java.lang.Class, java.lang.String, java.lang.String, int)'
java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Object, java.lang.Class, java.lang.String, java.lang.String, int)'
	at io.mockk.impl.JvmMockKGateway$mockTypeChecker$1.<init>(JvmMockKGateway.kt)
	at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:97)
	at io.mockk.impl.JvmMockKGateway.<clinit>(JvmMockKGateway.kt:172)
// -----------------------[ YOUR STACK TRACE ENDS HERE ] -----------------------

Minimal reproducible code (the gist of this issue)

// -----------------------[ GRADLE DEFINITIONS ] -----------------------

// -----------------------[ YOUR CODE STARTS HERE ] -----------------------
import io.mockk.every
import io.mockk.mockk
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test

class MockkTest {
  @Test
  fun test() {
    val mockk = mockk<Mocked> { every { hi() } returns "Hello world" }

    assertEquals(mockk.hi(), "Hello world")
  }
}

class Mocked {
  fun hi() = "there"
}

// -----------------------[ YOUR CODE ENDS HERE ] -----------------------

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

6reactions
Raibazcommented, Dec 16, 2020

I think I have found a fix for this, looks like the behavior for function references changed between kotlin 1.3 and 1.4, will include this in the next release which will hopefully support kotlin 1.3.* again.

0reactions
kaibadashcommented, Jul 26, 2022

I got same error. In my case I was able to fix that to remove "org.jetbrains.kotlin:kotlin-stdlib:1.3.72" . After Kotlin 1.4, we don’t need it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin releases
For 1.3.70, we had 2 bug fix releases – 1.3.71 and 1.3.72. For each incremental and feature release, we also ship several preview...
Read more >
assertk test shouldn't pass (nested alls / any ?) - Stack Overflow
Does anyone have a clue as to why this test is passing when it shouldn't? assertk version 0.23; junit version 5.7.0; kotlin version...
Read more >
Kotlin Multiplatform Libraries
Here is a list of Kotlin Multiplatform libraries with auto-fetch information directly ... A modern I/O library for Android, Java, and Kotlin Multiplatform....
Read more >
gradleApi() kotlin side-effects | by Martin Macura - Medium
Let's fix this. The only fix that worked for me, was to downgrade the library's kotlin version. That means changing the plugin's version...
Read more >
plugin version (1.6.21) is not the same as library version (1.7.10)
Starting from Kotlin 1.4 dependency on the standard library added by default: ... I solve this problem by changing my vpn,which make Android...
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