Jason Greene [
http://community.jboss.org/people/jason.greene] modified the document:
"Modular Serialization"
To view the document, visit:
http://community.jboss.org/docs/DOC-17244
--------------------------------------------------------------
h2. Understanding Class-loading Issues
When an object is serialized using Java serialization, the format consists of a
"class reference" and the field data of every field in all inheriting classes.
The class reference is simply a class name. *+The assumption is that the recieving party
has a all of the sender's class definitions readily accessable to the thread's
current context class loader.+* This means very different semantics than those commonly
expected in a normal in-vm invocation accross class loader boundaries. In a modularized
environment, it is not only common, but considered good practice to only share public API
types and yet still pass internal implementation classes that back the API types across
module boundaries. These "opaque" structures don't cause the VM a problem
because the same phsysical, already constructed, object instance is being passed around.
However, with serialization there is no object instance. All fields of all types that make
up an object need to be accessed to recreate the instance. Also since fields themesleves
may be references to other custom types, it is quite common for a large graph referencing
numerous types to be on the wire, and thus have a need for visibility.
h2. Problem A - Subclass Visibility
In this example a common super class is shared between a sender and a receiver, but an
extened subclass used by the sender's implementation is mistakenly not shared. This
case works just fine wiht local IN-VM invocations, but will fail once serialization is
involved.
http://community.jboss.org/servlet/JiveServlet/showImage/102-17244-4-1706...
http://community.jboss.org/servlet/JiveServlet/downloadImage/102-17244-4-...
h2. Problem B - Reference / Aggregation Visibility
In this example a common class is shared between a sender and a receiver, but it contains
a field which references a sender class that is mistakenly not shared. This case works
just fine with local IN-VM invocations, but will fail once serialization is involved.
http://community.jboss.org/servlet/JiveServlet/showImage/102-17244-4-1706...
http://community.jboss.org/servlet/JiveServlet/downloadImage/102-17244-4-...
--------------------------------------------------------------
Comment by going to Community
[
http://community.jboss.org/docs/DOC-17244]
Create a new document in JBoss AS7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=102&am...]