https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Jan

11/30/2021, 1:26 PM
I'm not sure what this error is trying to tell me:
Exception in thread "DefaultDispatcher-worker-3" java.lang.ClassCastException: class kotlin.reflect.jvm.internal.KTypeImpl cannot be cast to class kotlin.jvm.internal.TypeReference (kotlin.reflect.jvm.internal.KTypeImpl and kotlin.jvm.internal.TypeReference are in unnamed module of loader 'app')
at kotlin.jvm.internal.ReflectionFactory.mutableCollectionType(ReflectionFactory.java:107)
at kotlin.jvm.internal.Reflection.mutableCollectionType(Reflection.java:196)
at io.github.jan.discordkm.api.entities.interactions.commands.builders.ChatInputCommandBuilder.build$DiscordKM(ApplicationCommandBuilder.kt:211)
at io.github.jan.discordkm.api.entities.containers.CommandContainer.create(CommandContainer.kt:29)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invokeSuspend(DiscordWebSocketClient.kt:171)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invoke(DiscordWebSocketClient.kt)
at io.github.jan.therealbot.MainKt$main$$inlined$on$default$4.invoke(DiscordWebSocketClient.kt)
at io.github.jan.discordkm.api.events.EventListenerKt$EventListener$1.onEvent(EventListener.kt:21)
at io.github.jan.discordkm.api.events.EventListener$DefaultImpls.invoke(EventListener.kt:16)
at io.github.jan.discordkm.api.events.EventListenerKt$EventListener$1.invoke(EventListener.kt:20)
at io.github.jan.discordkm.api.entities.clients.DiscordWebSocketClient$handleEvent$2$1$1.invokeSuspend(DiscordWebSocketClient.kt:101)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
r

Rob Elliot

11/30/2021, 2:20 PM
Could you link to the commit with the right line numbers? The stacktrace references
ApplicationCommandBuilder.kt:211
but
ApplicationCommandBuilder.kt
only has 193 lines on master.
Oh hang on, it’s going to be inlined code from kotlinx.serialization mucking up the stack trace, I suspect…
Not an expert opinion but I’d be looking into whether there’s an incompatibility between the version of kotlinx.serialization that generated the object to json code and the version on the classpath at runtime. It’s possible that your code generation and runtime classpaths are different, or that you haven’t regenerated since upgrading kotlinx.serialization.
9 Views