Sdílet prostřednictvím


ObjectInputStream.ResolveObject(Object) Method

Definition

This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.

[Android.Runtime.Register("resolveObject", "(Ljava/lang/Object;)Ljava/lang/Object;", "GetResolveObject_Ljava_lang_Object_Handler")]
protected virtual Java.Lang.Object? ResolveObject (Java.Lang.Object? obj);
[<Android.Runtime.Register("resolveObject", "(Ljava/lang/Object;)Ljava/lang/Object;", "GetResolveObject_Ljava_lang_Object_Handler")>]
abstract member ResolveObject : Java.Lang.Object -> Java.Lang.Object
override this.ResolveObject : Java.Lang.Object -> Java.Lang.Object

Parameters

obj
Object

object to be substituted

Returns

the substituted object

Attributes

Exceptions

if any I/O error occurs while creating the replacement object.

Remarks

This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization. Replacing objects is disabled until enableResolveObject is called. The enableResolveObject method checks that the stream requesting to resolve object can be trusted. Every reference to serializable objects is passed to resolveObject. To insure that the private state of objects is not unintentionally exposed only trusted streams may use resolveObject.

This method is called after an object has been read but before it is returned from readObject. The default resolveObject method just returns the same object.

When a subclass is replacing objects it must insure that the substituted object is compatible with every field where the reference will be stored. Objects whose type is not a subclass of the type of the field or array element abort the serialization by raising an exception and the object is not be stored.

This method is called only once when each object is first encountered. All subsequent references to the object will be redirected to the new object.

Java documentation for java.io.ObjectInputStream.resolveObject(java.lang.Object).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also