I get the error "class not registered: HashMap$Values" since I use a HashMap and call .values() on it, passing the resulting Collection to a class that gets serialized and sent over the network by Kryonet / Kryo.
After some research, apparently HashMap itself is Serializable, but HashMap$Values is not, which is a private implementation class within HashMap and therefore completely inaccessible.
Although I solved this issue by doing (pseudocode) new ArrayList (HashMap.values()) I can't figure out why Kryo's MapSerializer cannot deal with this simple use case, and would like to know if there's a better way. Surely I'm not the only person to have encountered this problem?
I tried setting registration to be optional, which gets rid of the above error, but then that just results in a NullPointerException when the resulting Collection from HashMap$Values is actually accessed, I believe after deserialization.
I've read through the Kryo docs, searched Google, and read through all the Kryo & Kryonet issues / discussions on Google Groups and GitHub to no avail.
P.S. I'm using StdInstantiatorStrategy and apparently FieldSerializer attempts to serialize the HashMap$Values class instead of MapSerializer.
I get the error "class not registered: HashMap$Values" since I use a HashMap and call .values() on it, passing the resulting Collection to a class that gets serialized and sent over the network by Kryonet / Kryo.
After some research, apparently HashMap itself is Serializable, but HashMap$Values is not, which is a private implementation class within HashMap and therefore completely inaccessible.
Although I solved this issue by doing (pseudocode)
new ArrayList (HashMap.values())
I can't figure out why Kryo's MapSerializer cannot deal with this simple use case, and would like to know if there's a better way. Surely I'm not the only person to have encountered this problem?I tried setting registration to be optional, which gets rid of the above error, but then that just results in a NullPointerException when the resulting Collection from HashMap$Values is actually accessed, I believe after deserialization.
I've read through the Kryo docs, searched Google, and read through all the Kryo & Kryonet issues / discussions on Google Groups and GitHub to no avail.
P.S. I'm using StdInstantiatorStrategy and apparently FieldSerializer attempts to serialize the HashMap$Values class instead of MapSerializer.