The algorithm to compute the SerialVersionUID is described in Java Object Serialization Specification, Section 4.6, "Stream Unique Identifiers".
ObjectStreamField
, Java Object Serialization Specification, Section 4, "Class Descriptors"
Modifier and Type | Class and Description |
---|---|
private static class | |
pack-priv static class | ObjectStreamClass.
Class representing the portion of an object's serialized form allotted to data described by a given class descriptor. |
private static class | ObjectStreamClass.
A LRA cache of record deserialization constructors. |
private static class | ObjectStreamClass.
Contains information about InvalidClassException instances to be thrown when attempting operations on an invalid class. |
private static class | ObjectStreamClass.
Class for setting and retrieving serializable field values in batch. |
private static class | ObjectStreamClass.
FieldReflector cache lookup key. |
private static class | ObjectStreamClass.
Class for computing and caching field/constructor/method signatures during serialVersionUID calculation. |
pack-priv static class | ObjectStreamClass.
Record specific support for retrieving and binding stream field values. |
Modifier and Type | Field and Description |
---|---|
private MethodHandle | canonicalCtr
record canonical constructor (shared among OSCs for same class), or null |
private Class | cl
class associated with this descriptor (if any) |
private Constructor | cons
serialization-appropriate constructor, or null if none |
private volatile ObjectStreamClass. | dataLayout
data layout of serialized objects described by this class desc |
private ObjectStreamClass. | defaultSerializeEx
exception (if any) to throw if default serialization attempted |
private MethodHandle | deserializationCtr
session-cache of record deserialization constructor (in de-serialized OSC only), or null |
private ObjectStreamClass. | deserializationCtrs
cache of record deserialization constructors per unique set of stream fields (shared among OSCs for same class), or null |
private ObjectStreamClass. | deserializeEx
exception (if any) to throw if non-enum deserialization attempted |
private ProtectionDomain[] | domains
protection domains that need to be checked when calling the constructor |
private boolean | externalizable
true if represented class implements Externalizable |
private ObjectStreamClass. | fieldRefl
reflector for setting/getting serializable field values |
private ObjectStreamField[] | fields
serializable fields |
private boolean | hasBlockExternalData
true if desc has externalizable data written in block data format; this must be true by default to accommodate ObjectInputStream subclasses which override readClassDescriptor() to return class descriptors obtained from ObjectStreamClass.lookup() (see 4461737) |
private boolean | hasWriteObjectData
true if desc has data written by class-defined writeObject method |
private boolean | initialized
true if, and only if, the object has been correctly initialized |
private boolean | isEnum
true if represents enum type |
private boolean | isProxy
true if represents dynamic proxy class |
private boolean | isRecord
true if represents record type |
private ObjectStreamClass | localDesc
local class descriptor for represented class (may point to self) |
private String | name
name of class represented by this descriptor |
public static final ObjectStreamField[] | NO_FIELDS
serialPersistentFields value indicating no serializable fields |
private int | numObjFields
number of non-primitive fields |
private int | primDataSize
aggregate marshalled size of primitive fields |
private Method | readObjectMethod
class-defined readObject method, or null if none |
private Method | readObjectNoDataMethod
class-defined readObjectNoData method, or null if none |
private Method | readResolveMethod
class-defined readResolve method, or null if none |
private static final ReflectionFactory | reflFactory
reflection factory for obtaining serialization constructors |
private ClassNotFoundException | resolveEx
exception (if any) thrown while attempting to resolve class |
private boolean | serializable
true if represented class implements Serializable |
private ObjectStreamClass. | serializeEx
exception (if any) to throw if non-enum serialization attempted |
private static final ObjectStreamField[] | serialPersistentFields
|
private static final long | |
private volatile Long | suid
serialVersionUID of represented class (null if not computed yet) |
private ObjectStreamClass | superDesc
superclass descriptor appearing in stream |
private Method | writeObjectMethod
class-defined writeObject method, or null if none |
private Method | writeReplaceMethod
class-defined writeReplace method, or null if none |
Access | Constructor and Description |
---|---|
private | |
pack-priv | ObjectStreamClass()
Creates blank class descriptor which should be initialized via a subsequent call to initProxy(), initNonProxy() or readNonProxy(). |
Modifier and Type | Method and Description |
---|---|
private static MethodHandle | canonicalRecordCtr(Class<?> cls)
Returns the canonical constructor for the given record class, or null if the not found ( which should never happen for correctly generated record classes ). |
pack-priv void | checkDefaultSerialize()
Throws an InvalidClassException if objects whose class is represented by this descriptor should not be permitted to use default serialization (e.g., if the class declares serializable fields that do not correspond to actual fields, and hence must use the GetField API). |
pack-priv void | checkDeserialize()
Throws an InvalidClassException if object instances referencing this class descriptor should not be allowed to deserialize. |
pack-priv final void | |
pack-priv void | checkObjFieldValueTypes(Object obj, Object[] vals)
Checks that the given values, from array vals starting at offset 0, are assignable to the given serializable object fields. |
pack-priv void | checkSerialize()
Throws an InvalidClassException if objects whose class is represented by this descriptor should not be allowed to serialize. |
private static boolean | classNamesEqual(String name1, String name2)
Compares class names for equality, ignoring package names. |
private static long | |
private void | computeFieldOffsets()
Calculates and sets serializable field offsets, as well as primitive data size and object field count totals. |
public Class | Returns: theClass instance that this descriptor representsReturn the class in the local VM that this version is mapped to. |
pack-priv ObjectStreamClass. | getClassDataLayout()
Returns array of ClassDataSlot instances representing the data layout (including superclass data) for serialized objects described by this class descriptor. |
private ObjectStreamClass. | |
private static ObjectStreamField[] | getDeclaredSerialFields(Class<?> cl)
Returns serializable fields of given class as defined explicitly by a "serialPersistentFields" field, or null if no appropriate "serialPersistentFields" field is defined. |
private static Long | getDeclaredSUID(Class<?> cl)
Returns explicit serial version UID value declared by given class, or null if none. |
private static ObjectStreamField[] | getDefaultSerialFields(Class<?> cl)
Returns array of ObjectStreamFields corresponding to all non-static non-transient fields declared by given class. |
private static Constructor | getExternalizableConstructor(Class<?> cl)
Returns public no-arg constructor of given class, or null if none found. |
public ObjectStreamField | |
pack-priv ObjectStreamField | |
public ObjectStreamField[] | Returns: an array containing an element for each persistent field of this class. Returns an array of length zero if there are no fields.Return an array of the fields of this serializable class. |
pack-priv ObjectStreamField[] | getFields(boolean copy)
Returns arrays of ObjectStreamFields representing the serializable fields of the represented class. |
private static Method | getInheritableMethod(Class<?> cl, String name, Class<?>[] argTypes, Class<?> returnType)
Returns non-static, non-abstract method with given signature provided it is defined by or accessible (via inheritance) by the given class, or null if no match found. |
pack-priv ObjectStreamClass | getLocalDesc()
Returns the "local" class descriptor for the class associated with this class descriptor (i.e., the result of ObjectStreamClass.lookup(this.forClass())) or null if there is no class associated with this descriptor. |
private static String | getMethodSignature(Class<?>[] paramTypes, Class<?> retType)
Returns JVM type signature for given list of parameters and return type. |
public String | Returns: a string representing the name of the classReturns the name of the class described by this descriptor. |
pack-priv int | |
pack-priv void | getObjFieldValues(Object obj, Object[] vals)
Fetches the serializable object field values of object obj and stores them in array vals starting at offset 0. |
pack-priv int | getPrimDataSize()
Returns aggregate size (in bytes) of marshalled primitive field values for represented class. |
pack-priv void | getPrimFieldValues(Object obj, byte[] buf)
Fetches the serializable primitive field values of object obj and marshals them into byte array buf starting at offset 0. |
private static Method | getPrivateMethod(Class<?> cl, String name, Class<?>[] argTypes, Class<?> returnType)
Returns non-static private method with given signature defined by given class, or null if none found. |
private ProtectionDomain[] | Returns: An array of ProtectionDomain representing the set of ProtectionDomain that separate the concrete classcl
from its ancestor's declaring cons , or null .A constructor declared by cons, Class<?> cl or one of its
ancestors.A concrete class, which is either the class declaring
the constructor cl)cons , or a serializable subclass
of that class.Aggregate the ProtectionDomains of all the classes that separate
a concrete class |
pack-priv MethodHandle | getRecordConstructor()
Returns the canonical constructor, if the local class equivalent of this stream class descriptor is a record class, otherwise null. |
private static ObjectStreamClass. | getReflector(ObjectStreamField[] fields, ObjectStreamClass localDesc)
Matches given set of serializable fields with serializable fields described by the given local class descriptor, and returns a FieldReflector instance capable of setting/getting values from the subset of fields that match (non-matching fields are treated as filler, for which get operations return default values and set operations discard given values). |
pack-priv ClassNotFoundException | getResolveException()
Returns ClassNotFoundException (if any) thrown while attempting to resolve local class corresponding to this class descriptor. |
private static ObjectStreamField[] | getSerialFields(Class<?> cl)
Returns ObjectStreamField array describing the serializable fields of the given class. |
private static Constructor | getSerializableConstructor(Class<?> cl)
Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found. |
public long | Returns: the SUID of the class described by this descriptorReturn the serialVersionUID for this class. |
pack-priv ObjectStreamClass | |
private ObjectStreamClass | getVariantFor(Class<?> cl)
If given class is the same as the class associated with this class descriptor, returns reference to this class descriptor. |
pack-priv boolean | hasBlockExternalData()
Returns true if class descriptor represents externalizable class that has written its data in 1.2 (block data) format, false otherwise. |
pack-priv boolean | hasReadObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObject method. |
pack-priv boolean | hasReadObjectNoDataMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObjectNoData method. |
pack-priv boolean | hasReadResolveMethod()
Returns true if represented class is serializable or externalizable and defines a conformant readResolve method. |
private static native boolean | hasStaticInitializer(Class<?> cl)
Returns true if the given class defines a static initializer method, false otherwise. |
pack-priv boolean | hasWriteObjectData()
Returns true if class descriptor represents serializable (but not externalizable) class which has written its data via a custom writeObject() method, false otherwise. |
pack-priv boolean | hasWriteObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant writeObject method. |
pack-priv boolean | hasWriteReplaceMethod()
Returns true if represented class is serializable or externalizable and defines a conformant writeReplace method. |
private static native void | |
pack-priv void | initNonProxy(ObjectStreamClass model, Class<?> cl, ClassNotFoundException resolveEx, ObjectStreamClass superDesc)
Initializes class descriptor representing a non-proxy class. |
pack-priv void | initProxy(Class<?> cl, ClassNotFoundException resolveEx, ObjectStreamClass superDesc)
Initializes class descriptor representing a proxy class. |
pack-priv void | invokeReadObject(Object obj, ObjectInputStream in)
Invokes the readObject method of the represented serializable class. |
pack-priv void | invokeReadObjectNoData(Object obj)
Invokes the readObjectNoData method of the represented serializable class. |
pack-priv Object | invokeReadResolve(Object obj)
Invokes the readResolve method of the represented serializable class and returns the result. |
pack-priv void | invokeWriteObject(Object obj, ObjectOutputStream out)
Invokes the writeObject method of the represented serializable class. |
pack-priv Object | invokeWriteReplace(Object obj)
Invokes the writeReplace method of the represented serializable class and returns the result. |
pack-priv boolean | |
pack-priv boolean | |
pack-priv boolean | isInstantiable()
Returns true if represented class is serializable/externalizable and can be instantiated by the serialization runtime--i.e., if it is externalizable and defines a public no-arg constructor, or if it is non-externalizable and its first non-serializable superclass defines an accessible no-arg constructor. |
pack-priv boolean | |
pack-priv boolean | |
pack-priv boolean | |
public static ObjectStreamClass | |
pack-priv static ObjectStreamClass | |
public static ObjectStreamClass | Returns: the class descriptor for the specified classclass for which to get the descriptor cl)Returns the descriptor for any class, regardless of whether it
implements |
private static ObjectStreamField[] | matchFields(ObjectStreamField[] fields, ObjectStreamClass localDesc)
Matches given set of serializable fields with serializable fields obtained from the given local class descriptor (which contain bindings to reflective Field objects). |
pack-priv Object | |
private ProtectionDomain | |
private static boolean | packageEquals(Class<?> cl1, Class<?> cl2)
Returns true if classes are defined in the same runtime package, false otherwise. |
pack-priv void | readNonProxy(ObjectInputStream in)
Reads non-proxy class descriptor information from given input stream. |
private final void | |
pack-priv void | setObjFieldValues(Object obj, Object[] vals)
Sets the serializable object fields of object obj using values from array vals starting at offset 0. |
pack-priv void | setPrimFieldValues(Object obj, byte[] buf)
Sets the serializable primitive fields of object obj using values unmarshalled from byte array buf starting at offset 0. |
private static void | throwMiscException(Throwable th)
Convenience method for throwing an exception that is either a RuntimeException, Error, or of some unexpected type (in which case it is wrapped inside an IOException). |
public String | |
pack-priv void | writeNonProxy(ObjectOutputStream out)
Writes non-proxy class descriptor information to given output stream. |