Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KryoNet doesn't allow usage of Kryo 5.0.2's StdInstantiatorStrategy #161

Open
Daburnell112 opened this issue Jan 30, 2021 · 3 comments
Open

Comments

@Daburnell112
Copy link

Been working on a project since 2010 in Java, has been migrated through all the versions since. It's essentially outsider art what I'm working on.

Ran into a problem where I tried to serialize a SynchronizedRandomAccessList after migrating from Vectors both of which are part of the Java Standard Library. Easy way to do this, and how I'm going to fix it is simply modify the source of the Java Standard Library to add a no arg constructor for this. I shouldn't have to do this with any library.

What I should be doing is changing Kryo to use the standard strategy to StdInstantiatorStrategy as described in the Kryo Documentation, however KryoNet is using Kryo 2.2.0, instead of 5.0.2 and as such it doesn't exist that far back.

How to fix this:

Update Kryonet to use Kryo 5.x

How to reproduce it:

Try to declare a Instantiate Strategy with the library.

@Daburnell112
Copy link
Author

Can't modifiy the Java Standard Library anyway, so yeah.

Tried a workaround by using SerializationInstaniationStrategy and I'm getting

Caused by: org.objenesis.ObjenesisException: java.io.NotSerializableException: class com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP not serializable

So yeah, I'm gonna have to switch libraries. Worked 7 years ago when the last version came out, but doesn't work now.

@crykn
Copy link

crykn commented Jan 31, 2021

Hey @Daburnell112! This issue is basically a – more up to date – duplicate of #77 or any of the PRs that suggest updating the framework to Kryo 4.0. If you want to use Kryo 5 with Kryonet, your are best off taking a look at any of the forks that have already done this.

@Daburnell112
Copy link
Author

Alright I figured it out.

I ended up implementing the KryoSerializer class and changing the list to an array, deleting the reference to the list, and then serializing the class with the array.

I think the problem I encountered was that the code button to download a zip uses an outdated version of Kryo in the Jar file that's with the distributable. I built the jar file from one of the branches into a jar file with the latest Kryo build and I think it works.

Apart from that, I think I figured it out so the issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants