chpooo / kryo

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

unable ro write/readClass #77

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I first write a type for objects, that will be following later on
Output out = new Output(myOutStream);
Kryo k = new Kryo();
k.writeClass(out, String.class);
out.flush();

2. it just puts 0x03 on the wire

3. doing a k.readClass(in) just results in:
com.esotericsoftware.kryo.KryoException: Buffer underflow.
    at com.esotericsoftware.kryo.io.Input.require(Input.java:157)
    at com.esotericsoftware.kryo.io.Input.readInt(Input.java:302)
    at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:594)

What is the expected output? What do you see instead?
Documentation states, that the complete class name is to be transferred over 
the wire.
And readClass() should give me String.class instead of throwing an exception, 
of course.

What version of the Kryo are you using?
2.16

Please provide any additional information below.
I do not use class registration or custom serializers

Original issue reported on code.google.com by oreissig on 3 Jul 2012 at 2:51

GoogleCodeExporter commented 8 years ago
Works for me.

Kryo kryo = new Kryo();
Output output = new Output(1024);
kryo.writeClass(output, String.class);
System.out.println(kryo.readClass(new Input(output.toBytes())));

Original comment by nathan.s...@gmail.com on 7 Jul 2012 at 10:11

GoogleCodeExporter commented 8 years ago
so it's okay that serializing String.class doesn't actually send 
"java.lang.String" over the wire?

Original comment by oreissig on 18 Jul 2012 at 10:16

GoogleCodeExporter commented 8 years ago
Primitive, primitive wrappers, and String are regsitered by default.

Original comment by nathan.s...@gmail.com on 19 Jul 2012 at 8:18