andrewbissada / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

IllegalArgumentException when sending the Enum.class as an Object #147

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Output;

public class KryoTestEnumClass {

    public static void main(String args[]) {
        Output output = new Output(4096);
        try {
            new Kryo().writeClassAndObject(output, Enum.class);
        } finally {
            output.close();
        }
    }
}

What is the expected output? What do you see instead?
Should complete quietly (e.g. works fine for String.class), instead it throws 
the following Exception:
Exception in thread "main" java.lang.IllegalArgumentException: type cannot be 
null.
    at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:458)
    at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:467)
    at com.esotericsoftware.kryo.util.DefaultClassResolver.writeClass(DefaultClassResolver.java:79)
    at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:503)
    at com.esotericsoftware.kryo.serializers.DefaultSerializers$ClassSerializer.write(DefaultSerializers.java:233)
    at com.esotericsoftware.kryo.serializers.DefaultSerializers$ClassSerializer.write(DefaultSerializers.java:226)
    at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:614)
    at junk.KryoTestEnumClass.main(KryoTestEnumClass.java:11)

What version of the Kryo are you using?
kryo-2.22

Please provide any additional information below.
Note that this bug report relates to sending the Enum class, not an instance of 
an Enum.

For some background, one of the classes we were trying to serialize had a Class 
field, which failed only when it was set to the Enum.class

Original issue reported on code.google.com by brettsea...@gmail.com on 13 Nov 2013 at 12:26