java.io
Class ObjectStreamClass

java.lang.Object
  |
  +--java.io.ObjectStreamClass
All Implemented Interfaces:
Serializable

public class ObjectStreamClass
extends Object
implements Serializable

Untamed: 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.

Since:
JDK1.1
Version:
1.98 02/02/00
Author:
Mike Warres, Roger Riggs
See Also:
ObjectStreamField, Object Serialization Specification, Section 4, Class Descriptors, Serialized Form

Field Summary
private  Class cl
          class associated with this descriptor (if any)
private  java.lang.reflect.Constructor cons
          serialization-appropriate constructor, or null if none
private  java.io.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  java.io.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
          Enabled: serialPersistentFields value indicating no serializable fields
private  int numObjFields
          number of non-primitive fields
private  int primDataSize
          aggregate marshalled size of primitive fields
private  java.lang.reflect.Method readObjectMethod
          class-defined readObject method, or null if none
private  java.lang.reflect.Method readObjectNoDataMethod
          class-defined readObjectNoData method, or null if none
private  java.lang.reflect.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 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  java.lang.reflect.Method writeObjectMethod
          class-defined writeObject method, or null if none
private  java.lang.reflect.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.
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()
          Enabled: Return the class in the local VM that this version is mapped to.
(package private)  java.io.ObjectStreamClass.ClassDataSlot[] getClassDataLayout()
          Returns array of ClassDataSlot instances representing the data layout (including superclass data) for serialized objects described by this class descriptor.
private  java.io.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 java.lang.reflect.Constructor getExternalizableConstructor(Class cl)
          Returns public no-arg constructor of given class, or null if none found.
 ObjectStreamField getField(String name)
          Enabled: 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()
          Enabled: 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 java.lang.reflect.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()
          Enabled: 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.
(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 java.lang.reflect.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 java.io.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 java.lang.reflect.Constructor getSerializableConstructor(Class cl)
          Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found.
 long getSerialVersionUID()
          Enabled: 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)
          Enabled: 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 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()
          Suppressed: 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

NO_FIELDS

public static final ObjectStreamField[] NO_FIELDS
Enabled: serialPersistentFields value indicating no serializable fields


serialVersionUID

private static final long serialVersionUID

serialPersistentFields

private static final ObjectStreamField[] serialPersistentFields

reflFactory

private static final sun.reflect.ReflectionFactory reflFactory
reflection factory for obtaining serialization constructors


localDescs

private static final sun.misc.SoftCache localDescs
cache mapping local classes -> descriptors


reflectors

private static final sun.misc.SoftCache reflectors
cache mapping field group/local desc pairs -> field reflectors


cl

private Class cl
class associated with this descriptor (if any)


name

private String name
name of class represented by this descriptor


suid

private volatile Long suid
serialVersionUID of represented class (null if not computed yet)


isProxy

private boolean isProxy
true if represents dynamic proxy class


serializable

private boolean serializable
true if represented class implements Serializable


externalizable

private boolean externalizable
true if represented class implements Externalizable


hasWriteObjectData

private boolean hasWriteObjectData
true if desc has data written by class-defined writeObject method


hasBlockExternalData

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)


resolveEx

private ClassNotFoundException resolveEx
exception (if any) thrown while attempting to resolve class


deserializeEx

private InvalidClassException deserializeEx
exception (if any) to be thrown if deserialization attempted


defaultSerializeEx

private InvalidClassException defaultSerializeEx
exception (if any) to be thrown if default serialization attempted


fields

private ObjectStreamField[] fields
serializable fields


primDataSize

private int primDataSize
aggregate marshalled size of primitive fields


numObjFields

private int numObjFields
number of non-primitive fields


fieldRefl

private java.io.ObjectStreamClass.FieldReflector fieldRefl
reflector for setting/getting serializable field values


dataLayout

private volatile java.io.ObjectStreamClass.ClassDataSlot[] dataLayout
data layout of serialized objects described by this class desc


cons

private java.lang.reflect.Constructor cons
serialization-appropriate constructor, or null if none


writeObjectMethod

private java.lang.reflect.Method writeObjectMethod
class-defined writeObject method, or null if none


readObjectMethod

private java.lang.reflect.Method readObjectMethod
class-defined readObject method, or null if none


readObjectNoDataMethod

private java.lang.reflect.Method readObjectNoDataMethod
class-defined readObjectNoData method, or null if none


writeReplaceMethod

private java.lang.reflect.Method writeReplaceMethod
class-defined writeReplace method, or null if none


readResolveMethod

private java.lang.reflect.Method readResolveMethod
class-defined readResolve method, or null if none


localDesc

private ObjectStreamClass localDesc
local class descriptor for represented class (may point to self)


superDesc

private ObjectStreamClass superDesc
superclass descriptor appearing in stream

Constructor Detail

ObjectStreamClass

private ObjectStreamClass(Class cl)
Creates local class descriptor representing given class.


ObjectStreamClass

ObjectStreamClass()
Creates blank class descriptor which should be initialized via a subsequent call to initProxy(), initNonProxy() or readNonProxy().

Method Detail

initNative

private static void initNative()
Initializes native code.


lookup

public static ObjectStreamClass lookup(Class cl)
Enabled: Find the descriptor for a class that can be serialized. Creates an ObjectStreamClass instance if one does not exist yet for class. Null is returned if the specified class does not implement java.io.Serializable or java.io.Externalizable.

Parameters:
cl - class for which to get the descriptor
Returns:
the class descriptor for the specified class

getName

public String getName()
Enabled: The name of the class described by this descriptor.

Returns:
a String representing the fully qualified name of the class

getSerialVersionUID

public long getSerialVersionUID()
Enabled: Return the serialVersionUID for this class. The serialVersionUID defines a set of classes all with the same name that have evolved from a common root class and agree to be serialized and deserialized using a common format. NonSerializable classes have a serialVersionUID of 0L.

Returns:
the SUID of the class described by this descriptor

forClass

public Class forClass()
Enabled: Return the class in the local VM that this version is mapped to. Null is returned if there is no corresponding local class.

Returns:
the Class instance that this descriptor represents

getFields

public ObjectStreamField[] getFields()
Enabled: Return an array of the fields of this serializable class.

Returns:
an array containing an element for each persistent field of this class. Returns an array of length zero if there are no fields.
Since:
1.2

getField

public ObjectStreamField getField(String name)
Enabled: Get the field of this class by name.

Parameters:
name - the name of the data field to look for
Returns:
The ObjectStreamField object of the named field or null if there is no such named field.

toString

public String toString()
Suppressed: Return a string describing this ObjectStreamClass.

Overrides:
toString in class Object
Returns:
a string representation of the object.

lookup

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.

Parameters:
cl - class to look up
all - if true, return descriptors for all classes; if false, only return descriptors for serializable classes

initProxy

void initProxy(Class cl,
               ClassNotFoundException resolveEx,
               ObjectStreamClass superDesc)
         throws InvalidClassException
Initializes class descriptor representing a proxy class.

InvalidClassException

initNonProxy

void initNonProxy(ObjectStreamClass model,
                  Class cl,
                  ClassNotFoundException resolveEx,
                  ObjectStreamClass superDesc)
            throws InvalidClassException
Initializes class descriptor representing a non-proxy class.

InvalidClassException

readNonProxy

void readNonProxy(ObjectInputStream in)
            throws IOException,
                   ClassNotFoundException
Reads non-proxy class descriptor information from given input stream. The resulting class descriptor is not fully functional; it can only be used as input to the ObjectInputStream.resolveClass() and ObjectStreamClass.initNonProxy() methods.

IOException
ClassNotFoundException

writeNonProxy

void writeNonProxy(ObjectOutputStream out)
             throws IOException
Writes non-proxy class descriptor information to given output stream.

IOException

getResolveException

ClassNotFoundException getResolveException()
Returns ClassNotFoundException (if any) thrown while attempting to resolve local class corresponding to this class descriptor.


checkDeserialize

void checkDeserialize()
                throws InvalidClassException
Throws an InvalidClassException if object instances referencing this class descriptor should not be allowed to deserialize.

InvalidClassException

checkDefaultSerialize

void checkDefaultSerialize()
                     throws InvalidClassException
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).

InvalidClassException

getSuperDesc

ObjectStreamClass getSuperDesc()
Returns superclass descriptor. Note that on the receiving side, the superclass descriptor may be bound to a class that is not a superclass of the subclass descriptor's bound class.


getLocalDesc

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.


getFields

ObjectStreamField[] getFields(boolean copy)
Returns arrays of ObjectStreamFields representing the serializable fields of the represented class. If copy is true, a clone of this class descriptor's field array is returned, otherwise the array itself is returned.


getField

ObjectStreamField getField(String name,
                           Class type)
Looks up a serializable field of the represented class by name and type. A specified type of null matches all types, Object.class matches all non-primitive types, and any other non-null type matches assignable types only. Returns matching field, or null if no match found.


isProxy

boolean isProxy()
Returns true if class descriptor represents a dynamic proxy class, false otherwise.


isExternalizable

boolean isExternalizable()
Returns true if represented class implements Externalizable, false otherwise.


isSerializable

boolean isSerializable()
Returns true if represented class implements Serializable, false otherwise.


hasBlockExternalData

boolean hasBlockExternalData()
Returns true if class descriptor represents externalizable class that has written its data in 1.2 (block data) format, false otherwise.


hasWriteObjectData

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.


isInstantiable

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. Otherwise, returns false.


hasWriteObjectMethod

boolean hasWriteObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant writeObject method. Otherwise, returns false.


hasReadObjectMethod

boolean hasReadObjectMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObject method. Otherwise, returns false.


hasReadObjectNoDataMethod

boolean hasReadObjectNoDataMethod()
Returns true if represented class is serializable (but not externalizable) and defines a conformant readObjectNoData method. Otherwise, returns false.


hasWriteReplaceMethod

boolean hasWriteReplaceMethod()
Returns true if represented class is serializable or externalizable and defines a conformant writeReplace method. Otherwise, returns false.


hasReadResolveMethod

boolean hasReadResolveMethod()
Returns true if represented class is serializable or externalizable and defines a conformant readResolve method. Otherwise, returns false.


newInstance

Object newInstance()
             throws InstantiationException,
                    java.lang.reflect.InvocationTargetException,
                    UnsupportedOperationException
Creates a new instance of the represented class. If the class is externalizable, invokes its public no-arg constructor; otherwise, if the class is serializable, invokes the no-arg constructor of the first non-serializable superclass. Throws UnsupportedOperationException if this class descriptor is not associated with a class, if the associated class is non-serializable or if the appropriate no-arg constructor is inaccessible/unavailable.

InstantiationException
java.lang.reflect.InvocationTargetException
UnsupportedOperationException

invokeWriteObject

void invokeWriteObject(Object obj,
                       ObjectOutputStream out)
                 throws IOException,
                        UnsupportedOperationException
Invokes the writeObject method of the represented serializable class. Throws UnsupportedOperationException if this class descriptor is not associated with a class, or if the class is externalizable, non-serializable or does not define writeObject.

IOException
UnsupportedOperationException

invokeReadObject

void invokeReadObject(Object obj,
                      ObjectInputStream in)
                throws ClassNotFoundException,
                       IOException,
                       UnsupportedOperationException
Invokes the readObject method of the represented serializable class. Throws UnsupportedOperationException if this class descriptor is not associated with a class, or if the class is externalizable, non-serializable or does not define readObject.

ClassNotFoundException
IOException
UnsupportedOperationException

invokeReadObjectNoData

void invokeReadObjectNoData(Object obj)
                      throws IOException,
                             UnsupportedOperationException
Invokes the readObjectNoData method of the represented serializable class. Throws UnsupportedOperationException if this class descriptor is not associated with a class, or if the class is externalizable, non-serializable or does not define readObjectNoData.

IOException
UnsupportedOperationException

invokeWriteReplace

Object invokeWriteReplace(Object obj)
                    throws IOException,
                           UnsupportedOperationException
Invokes the writeReplace method of the represented serializable class and returns the result. Throws UnsupportedOperationException if this class descriptor is not associated with a class, or if the class is non-serializable or does not define writeReplace.

IOException
UnsupportedOperationException

invokeReadResolve

Object invokeReadResolve(Object obj)
                   throws IOException,
                          UnsupportedOperationException
Invokes the readResolve method of the represented serializable class and returns the result. Throws UnsupportedOperationException if this class descriptor is not associated with a class, or if the class is non-serializable or does not define readResolve.

IOException
UnsupportedOperationException

getClassDataLayout

java.io.ObjectStreamClass.ClassDataSlot[] getClassDataLayout()
                                                       throws InvalidClassException
Returns array of ClassDataSlot instances representing the data layout (including superclass data) for serialized objects described by this class descriptor. ClassDataSlots are ordered by inheritance with those containing "higher" superclasses appearing first. The final ClassDataSlot contains a reference to this descriptor.

InvalidClassException

getClassDataLayout0

private java.io.ObjectStreamClass.ClassDataSlot[] getClassDataLayout0()
                                                               throws InvalidClassException
InvalidClassException

getPrimDataSize

int getPrimDataSize()
Returns aggregate size (in bytes) of marshalled primitive field values for represented class.


getNumObjFields

int getNumObjFields()
Returns number of non-primitive serializable fields of represented class.


getPrimFieldValues

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. It is the responsibility of the caller to ensure that obj is of the proper type if non-null.


setPrimFieldValues

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. It is the responsibility of the caller to ensure that obj is of the proper type if non-null.


getObjFieldValues

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. It is the responsibility of the caller to ensure that obj is of the proper type if non-null.


setObjFieldValues

void setObjFieldValues(Object obj,
                       Object[] vals)
Sets the serializable object fields of object obj using values from array vals starting at offset 0. It is the responsibility of the caller to ensure that obj is of the proper type if non-null.


computeFieldOffsets

private void computeFieldOffsets()
                          throws InvalidClassException
Calculates and sets serializable field offsets, as well as primitive data size and object field count totals. Throws InvalidClassException if fields are illegally ordered.

InvalidClassException

getVariantFor

private ObjectStreamClass getVariantFor(Class cl)
                                 throws InvalidClassException
If given class is the same as the class associated with this class descriptor, returns reference to this class descriptor. Otherwise, returns variant of this class descriptor bound to given class.

InvalidClassException

getExternalizableConstructor

private static java.lang.reflect.Constructor getExternalizableConstructor(Class cl)
Returns public no-arg constructor of given class, or null if none found. Access checks are disabled on the returned constructor (if any), since the defining class may still be non-public.


getSerializableConstructor

private static java.lang.reflect.Constructor getSerializableConstructor(Class cl)
Returns subclass-accessible no-arg constructor of first non-serializable superclass, or null if none found. Access checks are disabled on the returned constructor (if any).


getInheritableMethod

private static java.lang.reflect.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. Access checks are disabled on the returned method (if any).


getPrivateMethod

private static java.lang.reflect.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. Access checks are disabled on the returned method (if any).


packageEquals

private static boolean packageEquals(Class cl1,
                                     Class cl2)
Returns true if classes are defined in the same package, false otherwise.


classNamesEqual

private static boolean classNamesEqual(String name1,
                                       String name2)
Compares class names for equality, ignoring package names. Returns true if class names equal, false otherwise.


getClassSignature

static String getClassSignature(Class cl)
Returns JVM type signature for given class.


getMethodSignature

private static String getMethodSignature(Class[] paramTypes,
                                         Class retType)
Returns JVM type signature for given list of parameters and return type.


throwMiscException

private static void throwMiscException(Throwable th)
                                throws IOException
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).

IOException

getSerialFields

private static ObjectStreamField[] getSerialFields(Class cl)
Returns ObjectStreamField array describing the serializable fields of the given class. Serializable fields backed by an actual field of the class are represented by ObjectStreamFields with corresponding non-null Field objects.


getDeclaredSerialFields

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. Serializable fields backed by an actual field of the class are represented by ObjectStreamFields with corresponding non-null Field objects. For compatibility with past releases, a "serialPersistentFields" field with a null value is considered equivalent to not declaring "serialPersistentFields".


getDefaultSerialFields

private static ObjectStreamField[] getDefaultSerialFields(Class cl)
Returns array of ObjectStreamFields corresponding to all non-static non-transient fields declared by given class. Each ObjectStreamField contains a Field object for the field it represents. If no default serializable fields exist, NO_FIELDS is returned.


getDeclaredSUID

private static Long getDeclaredSUID(Class cl)
Returns explicit serial version UID value declared by given class, or null if none.


computeDefaultSUID

private static long computeDefaultSUID(Class cl)
Computes the default serial version UID value for the given class.


hasStaticInitializer

private static boolean hasStaticInitializer(Class cl)
Returns true if the given class defines a static initializer method, false otherwise.


getReflector

private static java.io.ObjectStreamClass.FieldReflector getReflector(ObjectStreamField[] fields,
                                                                     ObjectStreamClass localDesc)
                                                              throws InvalidClassException
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). Throws InvalidClassException if unresolvable type conflicts exist between the two sets of fields.

InvalidClassException

matchFields

private static ObjectStreamField[] matchFields(ObjectStreamField[] fields,
                                               ObjectStreamClass localDesc)
                                        throws InvalidClassException
Matches given set of serializable fields with serializable fields obtained from the given local class descriptor (which contain bindings to reflective Field objects). Returns list of ObjectStreamFields in which each ObjectStreamField whose signature matches that of a local field contains a Field object for that field; unmatched ObjectStreamFields contain null Field objects. Shared/unshared settings of the returned ObjectStreamFields also reflect those of matched local ObjectStreamFields. Throws InvalidClassException if unresolvable type conflicts exist between the two sets of fields.

InvalidClassException


comments?