Michael Czeiszperger wrote:


If you wanted to de-serialize a class for which no definition existed you'd have to serialize the class definition as well, and somehow dynamically use a class loader to make it available. This would quickly get fairly complicated compared to the basic scenario.

They do it by annotating the serialized version in some fashion, with information needed to use a URLClassLoader to load the class from the other side. I've never actually used this feature, so I don't know exactly how (or how well) it works, but that's the gist of it.

Here's a quick snippet of what the Java RMI book says about it:

(page 428)

In Chapter 10, while discussing how RMI customizes the serialization algorithm, I said:

ObjectOutputStream calls annotateClass() when it writes out
class descriptions. Annotations are used to provide extra
information
about a class that comes from the serialization mechanism and not


    from the class itself.  The basic serialization mechanism has no
    real need
    for annotations, most of the information about a given class is
    already stored in the stream...

    RMI on the other hand, uses annotations to record codebase
    information. That is, RMI, in addition to recording the class
    descriptions, also records information about the location from which
    it loaded the class's bytecode.

These paragraphs, which may have seemed opaque before, should now make
more sense. RMI's dynamic classloading is based on two ideas:

   If an object is serialized and sent over the wire, the required class
    definitions might not be available on the other side.

   Automatically including URL's from which classes can be downloaded
   inside serialized objects allows special-purpose classloaders, such
   as the URLClassLoader, to automatically load classes from over the
   wire when they're needed to deserialize an object.

****** END SNIPPET ************

HTH, IANAL, Standard Disclaimers Apply, etc., blah...

TTYL,

Phil



_______________________________________________
Juglist mailing list
[EMAIL PROTECTED]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to