@Serializable objects cause compilation errors
See original GitHub issueHi when i run this code i get java.lang.NoSuchFieldError: Companion exception
.
fun main() {
val a = A // Throws java.lang.NoSuchFieldError: Companion
}
@Serializable
object A
@Serializer(forClass = A::class)
object ASerializer : KSerializer<A> {
override val descriptor = SerialClassDescImpl("ASerializer")
override fun serialize(encoder: Encoder, obj: A) = encoder.encodeString(obj::class.qualifiedName!!)
override fun deserialize(decoder: Decoder): A = decoder.decodeString().run { A }
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
java - Compile error on Serializable when ...
I am getting compilation error when compiling a Jdk8 codebase with OpenJdk11 on Serializable class with error : The type java.io.
Read more >Class Serialization Traits
Compile Time Warnings and Errors. Some serialization traits can conflict with other ones. Sometimes these conflicts will result in erroneous behavior (E.G. ...
Read more >Spark Error Task Not Serializable | The Startup
Cause of Task Not Serializable exception in Spark. Discusses functional interfaces in Java/Scala, closures, ObjectOutputStream.writeObject, Java 7 vs Java ...
Read more >Serialization in Java - Examples and Vulnerabilities
This article discusses serialization vulnerabilities in Java, factors that cause exposure, and strategies to prevent them. What is Serialization ...
Read more >Java Object Serialization Specification: 1 - System ...
Objects to be saved in the stream may support either the Serializable or the Externalizable interface. For Java TM objects, the serialized form...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Serializable object
is supported starting from Kotlin 1.3.60/kotlinx.serialization 0.14.0@pdvrieze I agree with what you are saying but this is a very early stage of the project so it will do for now. In the future I will have to change it to be more portable with a custom serializer for
sealed class Error
.