次の方法で共有


ISerial Interface

Definition

Indicates that an annotated field or method is part of the Serializable serialization mechanism defined by the <cite>Java Object Serialization Specification</cite>.

[Android.Runtime.Register("java/io/Serial", "", "Java.IO.ISerialInvoker", ApiSince=34)]
public interface ISerial : IDisposable, Java.Interop.IJavaPeerable, Java.Lang.Annotation.IAnnotation
[<Android.Runtime.Register("java/io/Serial", "", "Java.IO.ISerialInvoker", ApiSince=34)>]
type ISerial = interface
    interface IAnnotation
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Attributes
Implements

Remarks

Indicates that an annotated field or method is part of the Serializable serialization mechanism defined by the <cite>Java Object Serialization Specification</cite>. This annotation type is intended to allow compile-time checking of serialization-related declarations, analogous to the checking enabled by the java.lang.Override annotation type to validate method overriding. Serializable classes are encouraged to use @Serial annotations to help a compiler catch mis-declared serialization-related fields and methods, mis-declarations that may otherwise be difficult to detect.

Specifically, annotations of this type should be applied to serialization-related methods and fields in classes declared to be Serializable. The five serialization-related methods are:

<ul> <li>private void writeObject(java.io.ObjectOutputStream stream) throws IOException<li>private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException<li>private void readObjectNoData() throws ObjectStreamException<li>ANY-ACCESS-MODIFIERObject writeReplace() throws ObjectStreamException<li>ANY-ACCESS-MODIFIERObject readResolve() throws ObjectStreamException</ul>

The two serialization-related fields are:

<ul> <li>private static final ObjectStreamField[] serialPersistentFields<li>private static final long serialVersionUID</ul>

Compilers are encouraged to validate that a method or field marked with a @Serial annotation is one of the defined serialization-related methods or fields declared in a meaningful context and issue a warning if that is not the case.

It is a semantic error to apply this annotation to other fields or methods, including: <ul> <li>fields or methods in a class that is not Serializable<li>fields or methods of the proper structural declaration, but in a type where they are ineffectual. For example, enum types are defined to have a serialVersionUID of 0L so a serialVersionUID field declared in an enum type is ignored. The five serialization-related methods identified above are likewise ignored for an enum type.

<li>in a class that is Externalizable: <ul> <li> method declarations of writeObject, readObject, and readObjectNoData<li>a field declaration for serialPersistentFields</ul>

While the Externalizable interface extends Serializable, the three methods and one field above are <em>not</em> used for externalizable classes.

</ul>

Note that serialization mechanism accesses its designated fields and methods reflectively and those fields and methods may appear otherwise unused in a Serializable class.

Added in 14.

Java documentation for java.io.Serial.

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.

Properties

Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

AnnotationType()

Returns the annotation interface of this annotation.

(Inherited from IAnnotation)
Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
Equals(Object)

Returns true if the specified object represents an annotation that is logically equivalent to this one.

(Inherited from IAnnotation)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
GetHashCode()

Returns the hash code of this annotation.

(Inherited from IAnnotation)
SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
ToString()

Returns a string representation of this annotation.

(Inherited from IAnnotation)
UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to