logo       

De-Serialization Bug - Class Vector: msg#00403

hardware.microcontrollers.tini

Subject: De-Serialization Bug - Class Vector

Hello,

I have been figthing with a De-serialization problem in TINI, and it looks
more and more like a bug:

Find the code enclosed below:

The issue is: serializeTest will always serialize the Vector in
serializeTest: I have tested up to 120 elements.

However, De-serialization works only up to 40 elements , but fails at e.g.
50 with the following error:

Starting de-serializing // Printout from my code

java.lang.ClassCastException
in java.lang.reflect.Array.set(@JPC=15022d)
in java.io.ObjectInputStream.???
in java.io.ObjectInputStream.decodeTag(@JPC=160075)
in java.io.ObjectInputStream.readObject0(@JPC=290029)
in java.io.ObjectStreamClass.readObjectStreamField@JPC=1a015d)
in java.io.ObjectInputStream.defaultReadObject(@JPC=170023)
in java.io.ObjectInputStream.???
in java.io.ObjectInputStream.decodeTag(@JPC=16006d)
in java.io.ObjectInputStream.readObject0(@JPC=290029)
in java.io.ObjectInputStream.readObject(@JPC=280003)
in no.oss.rpc.simple.RPC.getSerializedObject(@JPC=1b0014)
in no.oss.rpc.simple.test.TestRPCReceiver.initialize(@JPC=11004e)
in no.oss.rpc.simple.test.TestRPCReceiver.<init>(@JPC=4)
in no.oss.rpc.simple.test.TestRPCAsServer.test(@JPC=a0004)
in java.lang.System.???



I thought it had something to do with the amount of data stored in the
Vector, so for 50 elements I changed addresses.addElement("Slituveien");
into addresses.addElement("S"); but I get the same exception.

This surely seems to be a bug or undocumented limitation. Any workaround?


Please Help !


Geir Ove
Norway

----------------- Code ---------------------------


Vector addresses = new Vector();
System.out.println("Vector capacity: " + addresses.capacity());

public voide serializeTest() {

for (int i = 0; i < 50; i++) {
//addresses.addElement("Slituveien");
addresses.addElement("S");
}

//TINIOS.setStackSize(5000);
try {
System.out.println("Starting serializing");
byte[] serializedVector = serializeObject(addresses);
System.gc();
Thread.sleep(1000);
System.out.println("Starting de-serializing");
Vector vector = (Vector)getSerializedObject(serializedVector);
System.out.println("Deserialized: " + vector);
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}

}


public static Object getSerializedObject(byte[] serializedData) throws
IOException, ClassNotFoundException {

ByteArrayInputStream byteInputStream = new
ByteArrayInputStream(serializedData, 0, serializedData.length);
ObjectInputStream objectInputStream = new
ObjectInputStream(byteInputStream);

return objectInputStream.readObject();
}


public static byte[] serializeObject(Object object) throws IOException {

ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(200);
ObjectOutputStream objectOutputStream = new
ObjectOutputStream(byteOutputStream);
objectOutputStream.writeObject(object);

return byteOutputStream.toByteArray();
}


_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/hBDgjK7y7TUQ@xxxxxxxxxxxxxxxx
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise