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.

"Can't locate class SealedClassSerializer from package kotlinx.serialization"

See original GitHub issue

IntelliJ IDEA throws this exception when compiling:

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: Backend Internal error: Exception during code generation
File being compiled at position: file:///home/johannes/projects/com.cedarsoft.monorepo/internal/closed/iris/src/main/java/com/cedarsoft/iris/photon/ImpactsForSource.kt
The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlinx.serialization.compiler.resolve.SearchUtilsKt.getFromPackage(SearchUtils.kt:72)
	at org.jetbrains.kotlin.codegen.CompilationErrorHandler.lambda$static$0(CompilationErrorHandler.java:35)
	at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:76)
	at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generatePackage(CodegenFactory.kt:96)
	at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generateModule(CodegenFactory.kt:67)
	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.doGenerateFiles(KotlinCodegenFacade.java:47)
	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:39)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:637)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:195)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:165)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:104)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1479)
	at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Can't locate class SealedClassSerializer from package kotlinx.serialization
	at org.jetbrains.kotlinx.serialization.compiler.resolve.SearchUtilsKt.getFromPackage(SearchUtils.kt:72)
	at org.jetbrains.kotlinx.serialization.compiler.resolve.SearchUtilsKt.getClassFromSerializationPackage(SearchUtils.kt:70)
	at org.jetbrains.kotlinx.serialization.compiler.resolve.KSerializationUtilKt.polymorphicSerializerIfApplicableAutomatically(KSerializationUtil.kt:169)
	at org.jetbrains.kotlinx.serialization.compiler.resolve.KSerializationUtilKt.getClassSerializer(KSerializationUtil.kt:180)
	at org.jetbrains.kotlinx.serialization.compiler.backend.common.TypeUtilKt.findTypeSerializer(TypeUtil.kt:168)
	at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializableCompanionCodegenImpl.generateSerializerGetter(SerializableCompanionCodegenImpl.kt:41)
	at org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCompanionCodegen.generate(SerializableCompanionCodegen.kt:47)
	at org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializableCompanionCodegenImpl$Companion.generateSerializableExtensions(SerializableCompanionCodegenImpl.kt:35)
	at org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationCodegenExtension.generateClassSyntheticParts(SerializationCodegenExtension.kt:31)
	at org.jetbrains.kotlin.codegen.ImplementationBodyCodegen.generateSyntheticPartsAfterBody(ImplementationBodyCodegen.java:438)
	at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:132)
	at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:302)
	at org.jetbrains.kotlin.codegen.MemberCodegen.genSyntheticClassOrObject(MemberCodegen.java:316)
	at org.jetbrains.kotlin.codegen.ClassBodyCodegen.generateBody(ClassBodyCodegen.java:111)
	at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:129)
	at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:302)
	at org.jetbrains.kotlin.codegen.MemberCodegen.genClassOrObject(MemberCodegen.java:286)
	at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateClassesAndObjectsInFile(PackageCodegenImpl.java:118)
	at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateFile(PackageCodegenImpl.java:137)
	at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:68)
	... 28 more

Any idea? Gradle builds just fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
sandwwraithcommented, Nov 19, 2019

Please wait until 0.14.0 released which is compatible with 1.3.60 release. It will happen in a couple of hours.

0reactions
nick0602commented, Nov 19, 2019

Tried 0.14.0 with 1.3.60 and the error is gone, thanks a lot again 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Third-party sealed classes serialization with `kotlinx ... - Medium
Serializer for class 'VariantA' is not found. Mark the class as @Serializable or provide the serializer explicitly. Checking documentation ...
Read more >
Proper way to serialize a sealed class with kotlinx-serialization
Serializing sealed classes works just fine. What is blocking you are the generic type parameters. You probably want to remove those, ...
Read more >
Kotlin on Twitter: "If you use the official kotlinx.serialization ...
If you use the official kotlinx.serialization library, we have good news for you. Since v0.14.0, sealed-classes hierarchies are serialized ...
Read more >
kotlinx.serialization.SealedClassSerializer
This class provides support for multiplatform polymorphic serialization of sealed classes. In contrary to PolymorphicSerializer, all known subclasses with ...
Read more >
[Solved]-can I use kotlinx serializer with multiple sealed class ...
You should serialize and deserialize using your sealed class in order for kotlin serialization to "know" to add a discriminator with the right ......
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