APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.rmi

public final Class MarshalledObject<T>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Type Parameters
<T>
the type of the object contained in this MarshalledObject
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .ObjectInputFilter, .ObjectInputStream, .ObjectOutputStream, .ObjectStreamConstants, .OutputStream, .Serializable, sun.rmi.server.MarshalInputStream, .MarshalOutputStream

A MarshalledObject contains a byte stream with the serialized representation of an object given to its constructor. The get method returns a new copy of the original object, as deserialized from the contained byte stream. The contained object is serialized and deserialized with the same serialization semantics used for marshaling and unmarshaling parameters and return values of RMI calls: When the serialized form is created:

When copy of the object is retrieved (via the get method), if the class is not available locally, it will be loaded from the appropriate location (specified the URL annotated with the class descriptor when the class was serialized.

MarshalledObject facilitates passing objects in RMI calls that are not automatically deserialized immediately by the remote peer.

Authors
Ann Wollrath, Peter Jones
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MarshalledObject.MarshalledObjectInputStream

The counterpart to MarshalledObjectOutputStream.

private static class
MarshalledObject.MarshalledObjectOutputStream

This class is used to marshal objects for MarshalledObject.

Field Summary

Modifier and TypeField and Description
private int
private byte[]
private byte[]
private transient ObjectInputFilter
objectInputFilter

Filter used when creating the instance from a stream; may be null.

private static final long
serialVersionUID

Indicate compatibility with 1.2 version of class.

Constructor Summary

AccessConstructor and Description
public
MarshalledObject(T
the object to be serialized (must be serializable)
obj
)

Creates a new MarshalledObject that contains the serialized representation of the current state of the supplied object.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the argument contains an equivalent serialized object; false otherwise
equals
(Object
the object to compare with this MarshalledObject
obj
)

Overrides java.lang.Object.equals.

Compares this MarshalledObject to another object.

public T

Returns:

a copy of the contained object
get
()

Returns a new copy of the contained marshalledobject.

public int

Returns:

a hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Return a hash code for this MarshalledObject.

private void
readObject(ObjectInputStream
the stream
stream
)

Reads in the state of the object and saves the stream's serialization filter to be used when the object is deserialized.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

hashback to summary
private int hash
See Also
hashCode
locBytesback to summary
private byte[] locBytes
objBytesback to summary
private byte[] objBytes
objectInputFilterback to summary
private transient ObjectInputFilter objectInputFilter

Filter used when creating the instance from a stream; may be null.

serialVersionUIDback to summary
private static final long serialVersionUID

Indicate compatibility with 1.2 version of class.

Constructor Detail

MarshalledObjectback to summary
public MarshalledObject(T obj) throws IOException

Creates a new MarshalledObject that contains the serialized representation of the current state of the supplied object. The object is serialized with the semantics used for marshaling parameters for RMI calls.

Parameters
obj:T

the object to be serialized (must be serializable)

Exceptions
IOException:
if an IOException occurs; an IOException may occur if obj is not serializable.
Since
1.2

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this MarshalledObject to another object. Returns true if and only if the argument refers to a MarshalledObject that contains exactly the same serialized representation of an object as this one does. The comparison ignores any class codebase annotation, meaning that two objects are equivalent if they have the same serialized representation except for the codebase of each class in the serialized representation.

Parameters
obj:Object

the object to compare with this MarshalledObject

Returns:boolean

true if the argument contains an equivalent serialized object; false otherwise

Since
1.2
getback to summary
public T get() throws IOException, ClassNotFoundException

Returns a new copy of the contained marshalledobject. The internal representation is deserialized with the semantics used for unmarshaling parameters for RMI calls. If the MarshalledObject was read from an ObjectInputStream, the filter from that stream is used to deserialize the object.

Returns:T

a copy of the contained object

Exceptions
IOException:
if an IOException occurs while deserializing the object from its internal representation.
ClassNotFoundException:
if a ClassNotFoundException occurs while deserializing the object from its internal representation. could not be found
Since
1.2
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Return a hash code for this MarshalledObject.

Returns:int

a hash code

readObjectback to summary
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException

Reads in the state of the object and saves the stream's serialization filter to be used when the object is deserialized.

Parameters
stream:ObjectInputStream

the stream

Exceptions
IOException:
if an I/O error occurs
ClassNotFoundException:
if a class cannot be found
java.rmi back to summary

private Class MarshalledObject.MarshalledObjectInputStream

extends MarshalInputStream
Class Inheritance

The counterpart to MarshalledObjectOutputStream.
See Also
MarshalledObjectOutputStream

Field Summary

Modifier and TypeField and Description
private ObjectInputStream
locIn

The stream from which annotations will be read.

Inherited from sun.rmi.server.MarshalInputStream:
permittedSunClasses

Constructor Summary

AccessConstructor and Description
pack-priv
MarshalledObjectInputStream(InputStream objIn, InputStream locIn, ObjectInputFilter filter)

Creates a new MarshalledObjectInputStream that reads its objects from objIn and annotations from locIn.

Method Summary

Modifier and TypeMethod and Description
protected Object
readLocation()

Overrides sun.rmi.server.MarshalInputStream.readLocation.

Overrides MarshalInputStream.readLocation to return locations from the stream we were given, or null if we were given a null location stream.

Inherited from sun.rmi.server.MarshalInputStream:
closedonegetDoneCallbackresolveClassresolveProxyClasssetDoneCallback

Field Detail

locInback to summary
private ObjectInputStream locIn

The stream from which annotations will be read. If this is null, then all annotations were null.

Constructor Detail

MarshalledObjectInputStreamback to summary
pack-priv MarshalledObjectInputStream(InputStream objIn, InputStream locIn, ObjectInputFilter filter) throws IOException

Creates a new MarshalledObjectInputStream that reads its objects from objIn and annotations from locIn. If locIn is null, then all annotations will be null.

Method Detail

readLocationback to summary
protected Object readLocation() throws IOException, ClassNotFoundException

Overrides sun.rmi.server.MarshalInputStream.readLocation.

Overrides MarshalInputStream.readLocation to return locations from the stream we were given, or null if we were given a null location stream.

java.rmi back to summary

private Class MarshalledObject.MarshalledObjectOutputStream

extends MarshalOutputStream
Class Inheritance

This class is used to marshal objects for MarshalledObject. It places the location annotations to one side so that two MarshalledObjects can be compared for equality if they differ only in location annotations. Objects written using this stream should be read back from a MarshalledObjectInputStream.
See Also
java.rmi.MarshalledObject, MarshalledObjectInputStream

Field Summary

Modifier and TypeField and Description
private boolean
hadAnnotations

true if non-null annotations are written.

private ObjectOutputStream
locOut

The stream on which location objects are written.

Constructor Summary

AccessConstructor and Description
pack-priv
MarshalledObjectOutputStream(OutputStream objOut, OutputStream locOut)

Creates a new MarshalledObjectOutputStream whose non-location bytes will be written to objOut and whose location annotations (if any) will be written to locOut.

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv boolean
hadAnnotations()

Returns true if any non-null location annotations have been written to this stream.

protected void
writeLocation(String loc)

Overrides sun.rmi.server.MarshalOutputStream.writeLocation.

Overrides MarshalOutputStream.writeLocation implementation to write annotations to the location stream.

Inherited from sun.rmi.server.MarshalOutputStream:
annotateClassannotateProxyClassreplaceObject

Field Detail

hadAnnotationsback to summary
private boolean hadAnnotations

true if non-null annotations are written.

locOutback to summary
private ObjectOutputStream locOut

The stream on which location objects are written.

Constructor Detail

MarshalledObjectOutputStreamback to summary
pack-priv MarshalledObjectOutputStream(OutputStream objOut, OutputStream locOut) throws IOException

Creates a new MarshalledObjectOutputStream whose non-location bytes will be written to objOut and whose location annotations (if any) will be written to locOut.

Method Detail

flushback to summary
public void flush() throws IOException

Overrides java.io.ObjectOutputStream.flush.

Implements java.io.ObjectOutput.flush, java.io.Flushable.flush.

Doc from java.io.ObjectOutputStream.flush.

Flushes the stream. This will write any buffered output bytes and flush through to the underlying stream.

Exceptions
IOException:
If an I/O error has occurred.
hadAnnotationsback to summary
pack-priv boolean hadAnnotations()

Returns true if any non-null location annotations have been written to this stream.

writeLocationback to summary
protected void writeLocation(String loc) throws IOException

Overrides sun.rmi.server.MarshalOutputStream.writeLocation.

Overrides MarshalOutputStream.writeLocation implementation to write annotations to the location stream.