|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.ObjectStreamClass
Serialization's descriptor for classes. It contains the name and serialVersionUID of the class. The ObjectStreamClass for a specific class loaded in this Java VM can be found/created using the lookup method.
The algorithm to compute the SerialVersionUID is described in Object Serialization Specification, Section 4.4, Stream Unique Identifiers.
ObjectStreamField
,
Object Serialization Specification, Section 4, Class Descriptors,
Serialized FormNested Class Summary | |
(package private) static class |
ObjectStreamClass.ClassDataSlot
Class representing the portion of an object's serialized form allotted to data described by a given class descriptor. |
private static class |
ObjectStreamClass.EntryFuture
Placeholder used in class descriptor and field reflector lookup tables for an entry in the process of being initialized. |
private static class |
ObjectStreamClass.FieldReflector
Class for setting and retrieving serializable field values in batch. |
private static class |
ObjectStreamClass.FieldReflectorKey
FieldReflector cache lookup key. |
private static class |
ObjectStreamClass.MemberSignature
Class for computing and caching field/constructor/method signatures during serialVersionUID calculation. |
Field Summary | |
private Class |
cl
class associated with this descriptor (if any) |
private Constructor |
cons
serialization-appropriate constructor, or null if none |
private ObjectStreamClass.ClassDataSlot[] |
dataLayout
data layout of serialized objects described by this class desc |
private InvalidClassException |
defaultSerializeEx
exception (if any) to be thrown if default serialization attempted |
private InvalidClassException |
deserializeEx
exception (if any) to be thrown if deserialization attempted |
private boolean |
externalizable
true if represented class implements Externalizable |
private ObjectStreamClass.FieldReflector |
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 accomodate 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 |
isProxy
true if represents dynamic proxy class |
private ObjectStreamClass |
localDesc
local class descriptor for represented class (may point to self) |
private static sun.misc.SoftCache |
localDescs
cache mapping local classes -> descriptors |
private String |
name
name of class represented by this descriptor |
static 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 sun.misc.SoftCache |
reflectors
cache mapping field group/local desc pairs -> field reflectors |
private static sun.reflect.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 InvalidClassException |
serializeEx
exception (if any) to be thrown if serialization attempted |
private static ObjectStreamField[] |
serialPersistentFields
|
private static long |
serialVersionUID
|
private 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 |
Constructor Summary | |
(package private) |
ObjectStreamClass()
Creates blank class descriptor which should be initialized via a subsequent call to initProxy(), initNonProxy() or readNonProxy(). |
private |
ObjectStreamClass(Class cl)
Creates local class descriptor representing given class. |
Method Summary | |
(package private) 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). |
(package private) void |
checkDeserialize()
Throws an InvalidClassException if object instances referencing this class descriptor should not be allowed to deserialize. |
(package private) 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 |
computeDefaultSUID(Class cl)
Computes the default serial version UID value for the given class. |
private void |
computeFieldOffsets()
Calculates and sets serializable field offsets, as well as primitive data size and object field count totals. |
Class |
forClass()
Return the class in the local VM that this version is mapped to. |
(package private) ObjectStreamClass.ClassDataSlot[] |
getClassDataLayout()
Returns array of ClassDataSlot instances representing the data layout (including superclass data) for serialized objects described by this class descriptor. |
private ObjectStreamClass.ClassDataSlot[] |
getClassDataLayout0()
|
(package private) static String |
getClassSignature(Class cl)
Returns JVM type signature for given class. |
private static ObjectStreamField[] |
getDeclaredSerialFields(Class cl)
Returns serializable fields of given class as defined explicitly by a "serialPersistentFields" field, or null if no appropriate "serialPersistendFields" 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. |
ObjectStreamField |
getField(String name)
Get the field of this class by name. |
(package private) ObjectStreamField |
getField(String name,
Class type)
Looks up a serializable field of the represented class by name and type. |
ObjectStreamField[] |
getFields()
Return an array of the fields of this serializable class. |
(package private) 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. |
(package private) 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. |
String |
getName()
The name of the class described by this descriptor. |
(package private) int |
getNumObjFields()
Returns number of non-primitive serializable fields of represented class. |
(package private) 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. |
private static String |
getPackageName(Class cl)
Returns package name of given class. |
(package private) int |
getPrimDataSize()
Returns aggregate size (in bytes) of marshalled primitive field values for represented class. |
(package private) 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 static ObjectStreamClass.FieldReflector |
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). |
(package private) 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. |
long |
getSerialVersionUID()
Return the serialVersionUID for this class. |
(package private) ObjectStreamClass |
getSuperDesc()
Returns superclass descriptor. |
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. |
(package private) boolean |
hasBlockExternalData()
Returns true if class descriptor represents externalizable class that has written its data in 1.2 (block data) format, false otherwise. |
(package private) boolean |
hasReadObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObject method. |
(package private) boolean |
hasReadObjectNoDataMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObjectNoData method. |
(package private) boolean |
hasReadResolveMethod()
Returns true if represented class is serializable or externalizable and defines a conformant readResolve method. |
private static boolean |
hasStaticInitializer(Class cl)
Returns true if the given class defines a static initializer method, false otherwise. |
(package private) 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. |
(package private) boolean |
hasWriteObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant writeObject method. |
(package private) boolean |
hasWriteReplaceMethod()
Returns true if represented class is serializable or externalizable and defines a conformant writeReplace method. |
private static void |
initNative()
Initializes native code. |
(package private) void |
initNonProxy(ObjectStreamClass model,
Class cl,
ClassNotFoundException resolveEx,
ObjectStreamClass superDesc)
Initializes class descriptor representing a non-proxy class. |
(package private) void |
initProxy(Class cl,
ClassNotFoundException resolveEx,
ObjectStreamClass superDesc)
Initializes class descriptor representing a proxy class. |
(package private) void |
invokeReadObject(Object obj,
ObjectInputStream in)
Invokes the readObject method of the represented serializable class. |
(package private) void |
invokeReadObjectNoData(Object obj)
Invokes the readObjectNoData method of the represented serializable class. |
(package private) Object |
invokeReadResolve(Object obj)
Invokes the readResolve method of the represented serializable class and returns the result. |
(package private) void |
invokeWriteObject(Object obj,
ObjectOutputStream out)
Invokes the writeObject method of the represented serializable class. |
(package private) Object |
invokeWriteReplace(Object obj)
Invokes the writeReplace method of the represented serializable class and returns the result. |
(package private) boolean |
isExternalizable()
Returns true if represented class implements Externalizable, false otherwise. |
(package private) 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. |
(package private) boolean |
isProxy()
Returns true if class descriptor represents a dynamic proxy class, false otherwise. |
(package private) boolean |
isSerializable()
Returns true if represented class implements Serializable, false otherwise. |
static ObjectStreamClass |
lookup(Class cl)
Find the descriptor for a class that can be serialized. |
(package private) static ObjectStreamClass |
lookup(Class cl,
boolean all)
Looks up and returns class descriptor for given class, or null if class is non-serializable and "all" is set to false. |
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). |
(package private) Object |
newInstance()
Creates a new instance of the represented class. |
private static boolean |
packageEquals(Class cl1,
Class cl2)
Returns true if classes are defined in the same runtime package, false otherwise. |
(package private) void |
readNonProxy(ObjectInputStream in)
Reads non-proxy class descriptor information from given input stream. |
(package private) void |
setObjFieldValues(Object obj,
Object[] vals)
Sets the serializable object fields of object obj using values from array vals starting at offset 0. |
(package private) 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). |
String |
toString()
Return a string describing this ObjectStreamClass. |
(package private) void |
writeNonProxy(ObjectOutputStream out)
Writes non-proxy class descriptor information to given output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final ObjectStreamField[] NO_FIELDS
private static final long serialVersionUID
private static final ObjectStreamField[] serialPersistentFields
private static final sun.reflect.ReflectionFactory reflFactory
private static final sun.misc.SoftCache localDescs
private static final sun.misc.SoftCache reflectors
private Class cl
private String name
private volatile Long suid
private boolean isProxy
private boolean serializable
private boolean externalizable
private boolean hasWriteObjectData
private boolean hasBlockExternalData
private ClassNotFoundException resolveEx
private InvalidClassException deserializeEx
private InvalidClassException serializeEx
private InvalidClassException defaultSerializeEx
private ObjectStreamField[] fields
private int primDataSize
private int numObjFields
private ObjectStreamClass.FieldReflector fieldRefl
private volatile ObjectStreamClass.ClassDataSlot[] dataLayout
private Constructor cons
private Method writeObjectMethod
private Method readObjectMethod
private Method readObjectNoDataMethod
private Method writeReplaceMethod
private Method readResolveMethod
private ObjectStreamClass localDesc
private ObjectStreamClass superDesc
Constructor Detail |
private ObjectStreamClass(Class cl)
ObjectStreamClass()
Method Detail |
private static void initNative()
public static ObjectStreamClass lookup(Class cl)
cl
- class for which to get the descriptor
public String getName()
String
representing the fully qualified name of
the classpublic long getSerialVersionUID()
public Class forClass()
Class
instance that this descriptor representspublic ObjectStreamField[] getFields()
public ObjectStreamField getField(String name)
name
- the name of the data field to look for
public String toString()
toString
in class Object
static ObjectStreamClass lookup(Class cl, boolean all)
cl
- class to look upall
- if true, return descriptors for all classes; if false, only
return descriptors for serializable classesvoid initProxy(Class cl, ClassNotFoundException resolveEx, ObjectStreamClass superDesc) throws InvalidClassException
InvalidClassException
void initNonProxy(ObjectStreamClass model, Class cl, ClassNotFoundException resolveEx, ObjectStreamClass superDesc) throws InvalidClassException
InvalidClassException
void readNonProxy(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
void writeNonProxy(ObjectOutputStream out) throws IOException
IOException
ClassNotFoundException getResolveException()
void checkDeserialize() throws InvalidClassException
InvalidClassException
void checkSerialize() throws InvalidClassException
InvalidClassException
void checkDefaultSerialize() throws InvalidClassException
InvalidClassException
ObjectStreamClass getSuperDesc()
ObjectStreamClass getLocalDesc()
ObjectStreamField[] getFields(boolean copy)
ObjectStreamField getField(String name, Class type)
boolean isProxy()
boolean isExternalizable()
boolean isSerializable()
boolean hasBlockExternalData()
boolean hasWriteObjectData()
boolean isInstantiable()
boolean hasWriteObjectMethod()
boolean hasReadObjectMethod()
boolean hasReadObjectNoDataMethod()
boolean hasWriteReplaceMethod()
boolean hasReadResolveMethod()
Object newInstance() throws InstantiationException, InvocationTargetException, UnsupportedOperationException
InstantiationException
InvocationTargetException
UnsupportedOperationException
void invokeWriteObject(Object obj, ObjectOutputStream out) throws IOException, UnsupportedOperationException
IOException
UnsupportedOperationException
void invokeReadObject(Object obj, ObjectInputStream in) throws ClassNotFoundException, IOException, UnsupportedOperationException
ClassNotFoundException
IOException
UnsupportedOperationException
void invokeReadObjectNoData(Object obj) throws IOException, UnsupportedOperationException
IOException
UnsupportedOperationException
Object invokeWriteReplace(Object obj) throws IOException, UnsupportedOperationException
IOException
UnsupportedOperationException
Object invokeReadResolve(Object obj) throws IOException, UnsupportedOperationException
IOException
UnsupportedOperationException
ObjectStreamClass.ClassDataSlot[] getClassDataLayout() throws InvalidClassException
InvalidClassException
private ObjectStreamClass.ClassDataSlot[] getClassDataLayout0() throws InvalidClassException
InvalidClassException
int getPrimDataSize()
int getNumObjFields()
void getPrimFieldValues(Object obj, byte[] buf)
void setPrimFieldValues(Object obj, byte[] buf)
void getObjFieldValues(Object obj, Object[] vals)
void setObjFieldValues(Object obj, Object[] vals)
private void computeFieldOffsets() throws InvalidClassException
InvalidClassException
private ObjectStreamClass getVariantFor(Class cl) throws InvalidClassException
InvalidClassException
private static Constructor getExternalizableConstructor(Class cl)
private static Constructor getSerializableConstructor(Class cl)
private static Method getInheritableMethod(Class cl, String name, Class[] argTypes, Class returnType)
private static Method getPrivateMethod(Class cl, String name, Class[] argTypes, Class returnType)
private static boolean packageEquals(Class cl1, Class cl2)
private static String getPackageName(Class cl)
private static boolean classNamesEqual(String name1, String name2)
static String getClassSignature(Class cl)
private static String getMethodSignature(Class[] paramTypes, Class retType)
private static void throwMiscException(Throwable th) throws IOException
IOException
private static ObjectStreamField[] getSerialFields(Class cl) throws InvalidClassException
InvalidClassException
private static ObjectStreamField[] getDeclaredSerialFields(Class cl) throws InvalidClassException
InvalidClassException
private static ObjectStreamField[] getDefaultSerialFields(Class cl)
private static Long getDeclaredSUID(Class cl)
private static long computeDefaultSUID(Class cl)
private static boolean hasStaticInitializer(Class cl)
private static ObjectStreamClass.FieldReflector getReflector(ObjectStreamField[] fields, ObjectStreamClass localDesc) throws InvalidClassException
InvalidClassException
private static ObjectStreamField[] matchFields(ObjectStreamField[] fields, ObjectStreamClass localDesc) throws InvalidClassException
InvalidClassException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |