[KryoNet] 'Field not declared as byte: 0'

I’m getting an Exception I’ve not got before, after I added another type of Message (simply a class for me):
[icode]
Exception in thread “LWJGL Application” java.lang.IllegalArgumentException: Field not declared as byte: 0
at org.matheusdev.ror.net.packages.CreateEntityFieldAccess.getByte(Unknown Source)
at com.esotericsoftware.kryo.serializers.FieldSerializer$ByteField.write(FieldSerializer.java:403)
at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:213)
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:571)
at com.esotericsoftware.kryonet.KryoSerialization.write(KryoSerialization.java:50)
at com.esotericsoftware.kryonet.TcpConnection.send(TcpConnection.java:192)
at com.esotericsoftware.kryonet.Connection.sendTCP(Connection.java:59)

[/icode]

But what does that mean?

In my game all Messages extend one class [icode]NetPackage[/icode]. I’ve changed it to include some info like that:


public abstract class NetPackage {

+   public static final byte TCP = 1;
+   public static final byte UDP = 2;

    public long time = 0;
+   public byte type = 0;

    public NetPackage() {
    }

    public NetPackage(long time, byte type) {
        this.time = time;
+       this.type = type;
    }
}

Now I get that exception (which says nothing useful to me, btw), and I don’t know why. I simply sent a subclass of NetPackage (both classes are registered, I checked it) over TCP to the Localhost on a port which worked all the time before…

What’s wrong?

Probably you have mismatched classes on either end of the network.

No, impossible, I use the same codebase for both client and server…

Not sure then, you’ll have to debug it, debug/trace logging, simpler testcase using only Kryo, etc.

You said you made a change, I assume undoing that change fixes it? Because its entirely possible something else is the problem. I’ve had that happen to me in the past that I was looking in the wrong place.

-.-

Seriously?
Kryo doesn’t like the variable name “type”… I’ve chnaged it to “connectionType” and it worked…
:cranky:

Seems like there has to be done something, Nate :point:
(To me, at least, it seems like a bug…)

There should be no problem “type” or any other field name. o.O Probably you classes were out of date, as I said. :slight_smile:

Impossible, no, they were not.
I’ve changed the code several times, everytime I changed something to test, whether the change makes it work, I restarted both server and client (which were both compiled with the newest code, of course).
Between two times running I simply changed the name of the variable from “type” to “connectiontype” and it worked.

It’s impossible I could have had two different class versions between my server and client. :expressionless: