Serialization Section Index | Page 4
How do I use the @serialField javadoc tag?
If you declare your serialiazable fields using the serialPersistentFields
member (see FAQ http://www.jguru.com/jguru/faq/view.jsp?EID=1197)
then you should document these fields using the
@serial...more
Can I pass Externalizable objects by value using RMI, or do the objects have to implement Serializable directly?
RMI will allow you to pass any object that is serializable according to
the serialization specification. This includes objects that implement
Externalizable as well as objects that implement Ser...more
What role does serialization have in RMI?
RMI uses serialization as its basic and only mechanism for
sending objects across a network.
If an object implements java.rmi.Remote, then the
object's stub is serialized and sent to the client...more
When using object streams over sockets, I have to flush the streams after each write operation. In fact I even have to flush the output stream soon after creation. Is there a way out of this?
The ObjectOutput interface provides a flush() method, implying
that implementations are allowed to buffer the output. The semantics of buffered
output are such that if you want the data to be se...more
Are there any other FAQs on Serialization?
Sun's "Frequently Asked Questions on RMI and Object Serialization" is available at
http://java.sun.com/products/jdk/1.2/docs/guide/rmi/faq.html.
This is a list of FAQs taken from the RMI...more
My subclass implements Serializable but my superclass doesn't. Both subclass and superclass contain instance variables that need to be saved as part of the state of the subclass. Will serialization save the superclass fields for me?
When you serialize an object, the serialization mechanism works by
chaining up the inheritence hierarchy, saving the sate of each
Serializable superclass in turn. When serialization reaches
the ...more
Can I serialize an array directly, or do I have to wrap it in an object first?
Although it's not obvious, arrays in Java are objects;
they have methods you can invoke (toString(), equals(), etc.) and contain
instance variables (length). The unnamed array superclass also im...more
How can I save an Image object using serialization?
java.awt.Image does not implement Serializable,
so if you need to send it to a stream using serialization you must access
the underlying data representation and write that representation out
expl...more
I'm having trouble getting Externalizable to work. Can you give a simple code example?
The following code defines a simple Externalizable class that
provides a main() method which instantiates an object,
writes it to a file, restores it, then verifies that the restored object
conta...more
What things are required for a class that implements Serializable?
A class that implements Serializable must also:
Have access to a no-argument constructor in its first non-serializable superclass
Identify non-serializable data members using
the transient keywor...more
What things are required for a class that implements Externalizable?
A class that implements Externalizable must also:
Have a public, no-argument constructor.
Provide a writeExternal(ObjectOutput) method to save the state of the object,
including the state of any ...more
How do I use the @serialData javadoc tag?
The @serialData javadoc tag is used to document
methods which generate a serialization format other than the default.
In particular, @serialData is typically used
to document the writeExternal() m...more
How do I use the @serial javadoc tag?
The @serial javadoc tag is used to document the meaning and
acceptable values of serialized fields. It appears in a javadoc
comment just prior to a field declaration, and is followed by a free-...more
How do I handle versioning of my Externalizable classes? Do I have to write a version number to the stream?
Just as with classes that implement Serializable, the serialVersionUID field
is checked when reading in Externalizable objects via an ObjectInputStream.
If serialVersionUID is not explicitly defi...more
Can I use an arbitrary long value for serialVersionUID when I declare it in my class?
If you don't have any previously serialized objects of that class
around, you can initialize serialVersionUID to any long
value you want. However, if you do have older versions of your class
and ...more