Problem serializing Java 16 records

235 views
Skip to first unread message

Stuart Sharpe

unread,
Jul 27, 2021, 3:11:16 PM7/27/21
to kryo-users
Hi,

I'm using Kryo 5.1.1 on JDK 16.0.2.

I am struggling to serialize records whose fields are not of a concrete type.

Please find attached a simple example. It declares a record with a field of type java.lang.Number, and constructs an instance of this using an Integer. Attempting to serialize the record fails with "Class is not registered: java.lang.Number" (registering java.lang.Number obviously doesn't help).

It works fine if the record's field is declared as a concrete type such as int or Integer. A regular class with a field of type Number also works fine.

Note that I am seeing this behaviour with fields of any interface type - java.lang.Number is just an example. I first ran into this after converting an existing class to a record which has a field of type java.util.Set.

Am I missing something? Any help would be appreciated.

Thanks

Stu
KyroRecordTest.java

Thomas Heigl

unread,
Jul 27, 2021, 4:46:27 PM7/27/21
to kryo-...@googlegroups.com
Hi Stuart,

Can you please create a GitHub issue for this?

Thanks,

Thomas

--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
---
You received this message because you are subscribed to the Google Groups "kryo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kryo-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kryo-users/520eade8-d582-4cc0-ad29-f01363793821n%40googlegroups.com.

Stuart Sharpe

unread,
Jul 28, 2021, 4:55:37 AM7/28/21
to kryo-users
Reply all
Reply to author
Forward
0 new messages