Is there a workaround for <https://github.com/mock...
# mockk
e
e
Does it work to downgrade jvmTarget to 11?
e
It's not possible for me to do that in my project so I can't test it
e
not possible? what happens if you do it? 😄
e
I'm using libraries that target jvm 17 so Gradle complains and says something about being incompatible
t
though I am wondering the same (about still being active) to be fair the problem is java 17 and kotlin 1.7. on java 11 and kotlin 1.7 mockking sealed class still works and the problem is with an underlined library, objenesis (https://github.com/easymock/objenesis), though once again, there is no new release in the past year, might be wise to figure out if it is possible to replace it
being OSS I won’t hold anyone responsible if they drop support, but I would like to know what the plans are so I could eventually look at finding an alternative
e
Exactly, I don't blame anyone, but I need to know if I should look for something else.
Also with Java 17 being an LTS, and with the push to update Java more frequently, I think it's definitely something that maintainers need to test and plan for.
e
I'm not involved, but can somebody at least put a standalone reproducible example into the issue? I just gave mockk 1.12.4 a shot in a sample project on Kotlin 1.7/Java 17 and it worked, so my simple setup doesn't capture whatever is going wrong
1
t
@ephemient added. https://github.com/ThanksForAllTheFish/mockk832 does it reproduce the issue for you too?
e
reproduced on my machine 👍
e
ok, I think I why I wasn't reproducing the issue before. I was still using the default
kotlinc -jvm-target 1.8
even with Java 17, but if you go up to
-jvm-target 17
(which
jvmToolchain
will do), then it breaks
as an immediate workaround, if I add
Copy code
kotlin {
    target.compilations.all {
        kotlinOptions.freeCompilerArgs += ["-jvm-target", "16"]
    }
}
then there's a warning about
-jvm-target
being specified multiple times, but the latter one wins and everything works
but going by a similar bug in Mockito/ECJ, this could be a Kotlin compiler issue and not something mockk can do anything about https://bugs.eclipse.org/bugs/show_bug.cgi?id=572190
t
I can also add a second branch replacing
mockk
with
mockative
, with that one the setting java 17+kotlin 1.7 works. but honestly, this type of issue is a bit beyond my capabilities
I think it is not an issue with mockk per se though, but with objenesis. let me try (later, just noticed I have a meeting in 5 minutes)