serialization

Serialization/deserialization ClassCastException: x cannot be cast to java.io.ObjectStreamClass

坚强是说给别人听的谎言 提交于 2020-01-04 13:24:13
问题 Using Java's native serialization, I'm intermittently seeing ClassCastExceptions java.lang.ClassCastException: myCompany.MyClass$MembershipServiceMethod cannot be cast to java.io.ObjectStreamClass or (less frequently) java.lang.ClassCastException: java.lang.String cannot be cast to java.io.ObjectStreamClass when I deserialize objects of a particular immutable class. That is to say, the exception is always thrown for particular serialized representations, but most objects can be successfully

Serialization/deserialization ClassCastException: x cannot be cast to java.io.ObjectStreamClass

∥☆過路亽.° 提交于 2020-01-04 13:24:02
问题 Using Java's native serialization, I'm intermittently seeing ClassCastExceptions java.lang.ClassCastException: myCompany.MyClass$MembershipServiceMethod cannot be cast to java.io.ObjectStreamClass or (less frequently) java.lang.ClassCastException: java.lang.String cannot be cast to java.io.ObjectStreamClass when I deserialize objects of a particular immutable class. That is to say, the exception is always thrown for particular serialized representations, but most objects can be successfully

XmlDictionaryReader reading fixed-size zeroed Stream

ぃ、小莉子 提交于 2020-01-04 12:48:57
问题 Can someone give me good explanation why this has to fail? const int bufferSize = 2 * 1024, testValue = 123456; var buffer = new byte[bufferSize]; var serializer = new DataContractSerializer(typeof(int)); //Serialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(memStream)) serializer.WriteObject(writer, testValue); //Deserialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryReader

XmlDictionaryReader reading fixed-size zeroed Stream

我怕爱的太早我们不能终老 提交于 2020-01-04 12:48:53
问题 Can someone give me good explanation why this has to fail? const int bufferSize = 2 * 1024, testValue = 123456; var buffer = new byte[bufferSize]; var serializer = new DataContractSerializer(typeof(int)); //Serialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(memStream)) serializer.WriteObject(writer, testValue); //Deserialize value using (var memStream = new MemoryStream(buffer)) using (XmlDictionaryReader

Serialize HashMap as root element with Simple

我的未来我决定 提交于 2020-01-04 11:05:37
问题 I want to serialize an element that extends HashMap with Simple. @Root(name = "settings") @ElementMap(entry="element", key="id", attribute=true, required=true, empty=true) public class Settings extends HashMap<String, Object> { ... Whenever I serialize it, I get no errors, but I also get an empty file that looks like this: <settings/> Is there any way to do this without creating an inner object instead, and then having to delegate all of the methods to it? 回答1: I suppose the reason is, that

Serialize HashMap as root element with Simple

馋奶兔 提交于 2020-01-04 11:05:09
问题 I want to serialize an element that extends HashMap with Simple. @Root(name = "settings") @ElementMap(entry="element", key="id", attribute=true, required=true, empty=true) public class Settings extends HashMap<String, Object> { ... Whenever I serialize it, I get no errors, but I also get an empty file that looks like this: <settings/> Is there any way to do this without creating an inner object instead, and then having to delegate all of the methods to it? 回答1: I suppose the reason is, that

Unity Doesnt Serialize int? field

狂风中的少年 提交于 2020-01-04 09:37:12
问题 I have a class i want to change the properties of in the editor. So i made my class System.Serializable and made the variables public that i want to be able to change. Like so: [System.Serializable] public class UIOptionsRing { public float Radius, DistanceBetweenPoints, StartOffset, GapInDegrees; public int? GapAfterElementNumer = 3; //this var doesnt show up public Vector3 CircleCenter; public GameObject CircleElementsContainer; } But the problem i am having is that the GapAfterElementNumer

C++/Java serialization library suitable for socket stream?

不想你离开。 提交于 2020-01-04 09:19:31
问题 I need to write a server in C++/Obj-C that can receive streamed data from several clients built in Java and C++. The challenge: I need to serialize and deserialize the data structures efficiently. One C++ client will be generating 128x96x2-dimensional float arrays, plus some metadata, about 30 times per second (video features). A Java client will be generating a smaller feature vector -- probably 200 values, 1-10 times per second. I've about resigned myself to rolling my own implementation,

Using C# xmlserializer on derived classes while controlling the generated XML element

为君一笑 提交于 2020-01-04 09:09:22
问题 I've got a C# structure of classes with an abstract base class and various classes derived from this abstract class. [System.Xml.Serialization.XmlInclude(typeof(B))] public abstract class A { ... } [Serializable] [XmlType("typename")] public class B : A { ... } Furthermore, I'm using an instance of class B within another class C as a field with its abstract type like this: public class C { ... public A myItem { get; set; } //A is actually of type B ... } Now, when I serialize my class C via

Using C# xmlserializer on derived classes while controlling the generated XML element

折月煮酒 提交于 2020-01-04 09:09:11
问题 I've got a C# structure of classes with an abstract base class and various classes derived from this abstract class. [System.Xml.Serialization.XmlInclude(typeof(B))] public abstract class A { ... } [Serializable] [XmlType("typename")] public class B : A { ... } Furthermore, I'm using an instance of class B within another class C as a field with its abstract type like this: public class C { ... public A myItem { get; set; } //A is actually of type B ... } Now, when I serialize my class C via