Skip to content

Mockito cannot mock/spy because : VM does not support modification of given type #441

@MastaP

Description

@MastaP

Hi,

After switching kotlin's api/language from 1.4 to 1.5, the following code:

    @Test
    fun test() {
        val deferredSupplier = spy(Supplier { Flux.empty<String>() })
        Flux.defer(deferredSupplier).blockLast()
        verify(deferredSupplier, times(1)).get()
    }

fails with

Cannot mock/spy class com.example.Test$$Lambda$318/0x00000008001dc840
Mockito cannot mock/spy because :
 - VM does not support modification of given type

I'm using org.mockito.kotlin:mockito-kotlin:3.2.0 and org.mockito:mockito-inline:3.12.4
The issue is reproduced in the following project, where the only difference between two commits is changing Kotlin's api from 1.4 to 1.5
https://github.com/MastaP/mockito-kotlin15-bug/actions
Kotlin version: 1.5.30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions