kordlib/kord

Exception in TimeSourceIntervalRateLimiter with Kotlin 1.7.0

malliaridis opened this issue · 2 comments

Description

Exeucting the basic example from the readme with Kotlin 1.7.0 returns the following error message. Same code with Kotlin 1.6.21 works fine.

Steps to reproduce

  1. Have a configured discord bot with correct privileges
  2. Setup a basic Gradle project
  3. Add the dependencies
  4. Copy the code from the readme.md or use the code below:
suspend fun main() {
    val kord = Kord("your bot token")
    val pingPong = ReactionEmoji.Unicode("\uD83C\uDFD3")

    kord.on<MessageCreateEvent> {
        if (message.content != "!ping") return@on

        val response = message.channel.createMessage("Pong!")
        response.addReaction(pingPong)

        delay(5000)
        message.delete()
        response.delete()
    }

    kord.login {
        @OptIn(PrivilegedIntent::class)
        intents += Intent.MessageContent
    }
}

Exception

Stacktrace ```txt Exception in thread "main" java.lang.IncompatibleClassChangeError: class dev.kord.common.ratelimit.TimeSourceIntervalRateLimiter$Companion$DISTANT_PAST_MARK$1 has interface kotlin.time.TimeMark as super class at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:855) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:753) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:676) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) at dev.kord.common.ratelimit.TimeSourceIntervalRateLimiter.(TimeSourceIntervalRateLimiter.kt:41) at dev.kord.common.ratelimit.RateLimiterKt.IntervalRateLimiter-8Mi8wO0(RateLimiter.kt:65) at dev.kord.common.ratelimit.RateLimiterKt.IntervalRateLimiter-8Mi8wO0$default(RateLimiter.kt:61) at dev.kord.rest.ratelimit.AbstractRateLimiter.(AbstractRateLimiter.kt:21) at dev.kord.rest.ratelimit.ExclusionRequestRateLimiter.(ExclusionRequestRateLimiter.kt:20) at dev.kord.rest.ratelimit.ExclusionRequestRateLimiter.(ExclusionRequestRateLimiter.kt:20) at dev.kord.core.builder.kord.KordBuilder$handlerBuilder$1.invoke(KordBuilder.kt:75) at dev.kord.core.builder.kord.KordBuilder$handlerBuilder$1.invoke(KordBuilder.kt:75) at dev.kord.core.builder.kord.KordBuilder.build(KordBuilder.kt:243) at dev.kord.core.builder.kord.KordBuilder$build$1.invokeSuspend(KordBuilder.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112) at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112) at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112) at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112) at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14) at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178) at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328) at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1412) at kotlinx.coroutines.JobSupport.notifyCompletion(JobSupport.kt:1519) at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:323) at kotlinx.coroutines.JobSupport.finalizeFinishingState(JobSupport.kt:240) at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:906) at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:863) at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:828) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:100) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) ```

Expected Behavior

It is expected after the upgrade / changes with Kotlin 1.7.0 that the application just runs out of the box.

Actual Behavior

The application does not run.

You can't use kotlin 1.7 yet, they changed the still experimental TimeMark we rely on from abstract class to interface which is a binary incompatible change.
Kord must be recompiled for Kotlin 1.7 (the newest snapshot version uses Kotlin 1.7 and should work).

I see, so the changes for 1.7.0 are still experimental and 1.6.21 is the version to go for right now. I think we can close this issue then. 👍

Thanks for the quick response btw. 😄