Skip to content
New issue

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

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

Already on GitHub? # to your account

Minor Improvement: Kryo.readObject should detect an abstract class and throw an IllegalArgumentException #857

Open
buko opened this issue Sep 17, 2021 · 1 comment

Comments

@buko
Copy link

buko commented Sep 17, 2021

This is a very minor improvement to provide more helpful error messages:

Describe the solution you'd like

Calls to Kryo.readObject(Input, Class) will throw an exception if passed an abstract class:

com.esotericsoftware.kryo.kryo5.KryoException: Error constructing instance of class: 

This of course makes sense but the error message isn't very helpful. It doesn't actually explain why the the class couldn't be constructed. The underlying java.lang.InstantiationException provides zero information.

A more helpful protocol might be for kryo.readObject would immediately detect that it's being asked to instantiate an abstract class and raise an IllegalArgumentException.

@NathanSweet
Copy link
Member

Good candidate for a PR.

# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

3 participants