java - Deserialization to an interface type returns null -



java - Deserialization to an interface type returns null -

i have next scenario:

interface a{ } class x implements a, serializable{ }

program p1 knows both a , x , serializes object objx of class x byte array byax.

then, p1 sends byax programme p2 through middleware.

p2 knows interface a. deserializes byax object of type a. problem operation returns null.

the serialization in p1 implemented this:

bytearrayoutputstream bos = new bytearrayoutputstream(); objectoutput out = null; seek { out = new objectoutputstream(bos); out.writeobject(objx); byte[] byax = bos.tobytearray(); ...

the deserialization in p2 implemented this:

bytearrayinputstream bis = new bytearrayinputstream(byax); objectinput in = new objectinputstream(bis); obja = (a) in.readobject();

object obja gets null after line a obja = (a) in.readobject();

can't deserialize interface type?

where mistake?

thanks lot,

guilherme

java serialization interface bytearray deserialization

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -