Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate SerialVersionUID for Kotlin classes in IntelliJ

On Intellij, how would you be able to generate a SerialVersionUID for classes that are written in Kotlin?

I've enabled the inspection in Intellij that does this:

Reports any Serializable classes which do not provide a serialVersionUID field. Without a serialVersionUID field, any change to a class will make previously serialized versions unreadable.

But this only works with Java classes

like image 866
Zocp Avatar asked Oct 17 '22 21:10

Zocp


1 Answers

You are right. This inspection does not work for Kotlin classes. Maybe you could file an issue to Jetbrains so that they could fix it.

For generation of SerialVersionUID you can use JDK's build-in command serialver.

E:\workspace\target\classes>serialver Address

Address: static final long serialVersionUID = -687991492884005033L;

Other usage examples.

like image 173
Januson Avatar answered Oct 21 '22 01:10

Januson