Well, this may not be too "advanced" for most people, but I'm unsure how to approach it...
I have a package written by someone else whose objects I now need to serialize. The package has several classes with complex relationships (objects frequently share the same objects), lots of inheritance, and is lacking in default constructors. (It's also lacking in documentation...)
The primary object I want to serialize takes two other objects from the package as parameters. It processes up to a certain point, and then I want to store it's exact state for later use. I've taken a stab at serializing it with no luck, but lots of NullPointerExceptions.
Is there any sure-fire method for serializing complex objects like this? (For instance, making every single class serializable or something.) Do I need to add default constructors? If so, do I actually need to add logic to them, or can they be empty? Would I basically need to get a PhD in understanding this package for this to work?
I don't care too much about the cost of storing the object, just that I can get it back in the exact state.
i have found a good bit of success using some serializer library, such as "SOJO" or "JSONSerializer" (both sourceforge projects). They usually work with bean pattern methods and require objects have default constructors, but are capable of serializing complex objects with nested lists and other objects very well. Where as to use java serialization is more difficult, requiring they implement serializable and you would likely need to provide your own readObject() and writeObject() methods in some of the more complex classes.