次の方法で共有


ObjectInputStream.ResolveClass(ObjectStreamClass) Method

Definition

Load the local class equivalent of the specified stream class description.

[Android.Runtime.Register("resolveClass", "(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;", "GetResolveClass_Ljava_io_ObjectStreamClass_Handler")]
protected virtual Java.Lang.Class? ResolveClass (Java.IO.ObjectStreamClass? desc);
[<Android.Runtime.Register("resolveClass", "(Ljava/io/ObjectStreamClass;)Ljava/lang/Class;", "GetResolveClass_Ljava_io_ObjectStreamClass_Handler")>]
abstract member ResolveClass : Java.IO.ObjectStreamClass -> Java.Lang.Class
override this.ResolveClass : Java.IO.ObjectStreamClass -> Java.Lang.Class

Parameters

desc
ObjectStreamClass

an instance of class ObjectStreamClass

Returns

a Class object corresponding to desc

Attributes

Exceptions

if the class for an object cannot be found.

if an I/O error occurs while creating the class.

Remarks

Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, if the class is not an array class, its serialVersionUID is compared to the serialVersionUID of the serialized class, and if there is a mismatch, the deserialization fails and an InvalidClassException is thrown.

The default implementation of this method in ObjectInputStream returns the result of calling

Class.forName(desc.getName(), false, loader)

where loader is determined as follows: if there is a method on the current thread's stack whose declaring class was defined by a user-defined class loader (and was not a generated to implement reflective invocations), then loader is class loader corresponding to the closest such method to the currently executing frame; otherwise, loader is null. If this call results in a ClassNotFoundException and the name of the passed ObjectStreamClass instance is the Java language keyword for a primitive type or void, then the Class object representing that primitive type or void will be returned (e.g., an ObjectStreamClass with the name "int" will be resolved to Integer.TYPE). Otherwise, the ClassNotFoundException will be thrown to the caller of this method.

Java documentation for java.io.ObjectInputStream.resolveClass(java.io.ObjectStreamClass).

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