Methods
pack-private 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).
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). This method
does not apply to deserialization of enum constants.
pack-private void
checkDeserialize
()
throws
InvalidClassException
Throws an InvalidClassException if object instances referencing this
class descriptor should not be allowed to deserialize.
Throws an InvalidClassException if object instances referencing this
class descriptor should not be allowed to deserialize. This method does
not apply to deserialization of enum constants.
pack-private void
checkSerialize
()
throws
InvalidClassException
Throws an InvalidClassException if objects whose class is represented by
this descriptor should not be allowed to serialize.
Throws an InvalidClassException if objects whose class is represented by
this descriptor should not be allowed to serialize. This method does
not apply to serialization of enum constants.
public Class<
Object>
forClass
()
Return the class in the local VM that this version is mapped to.
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
pack-private ClassDataSlot
getClassDataLayout
()
throws
InvalidClassException
Returns array of ClassDataSlot instances representing the data layout
(including superclass data) for serialized objects described by this
class descriptor.
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.
pack-privatestatic String
getClassSignature
(
Class cl)
Returns JVM type signature for given class.
public ObjectStreamField
getField
(
String name)
Get the field of this class by name.
Get the field of this class by name.
Returns:
The ObjectStreamField object of the named field or null if
there is no such named field.
Parameters:
-
name - the name of the data field to look for
pack-private ObjectStreamField
getField
(
String name,
Class type)
Looks up a serializable field of the represented class by name and 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.
public ObjectStreamField
getFields
()
Return an array of the fields of this serializable class.
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
pack-private ObjectStreamField
getFields
(
boolean copy)
Returns arrays of ObjectStreamFields representing the serializable
fields of the represented class.
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.
pack-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.
public String
getName
()
Returns the name of the class described by this descriptor.
Returns the name of the class described by this descriptor.
This method returns the name of the class in the format that
is used by the
Class.getName()
method.
Returns:
a string representing the name of the class
pack-private int
getNumObjFields
()
Returns number of non-primitive serializable fields of represented
class.
pack-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.
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.
pack-private int
getPrimDataSize
()
Returns aggregate size (in bytes) of marshalled primitive field values
for represented class.
pack-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.
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.
pack-private ClassNotFoundException
getResolveException
()
Returns ClassNotFoundException (if any) thrown while attempting to
resolve local class corresponding to this class descriptor.
public long
getSerialVersionUID
()
Return the serialVersionUID for this class.
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
pack-private ObjectStreamClass
getSuperDesc
()
Returns superclass descriptor.
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.
pack-private boolean
hasBlockExternalData
()
Returns true if class descriptor represents externalizable class that
has written its data in 1.2 (block data) format, false otherwise.
pack-private boolean
hasReadObjectMethod
()
Returns true if represented class is serializable (but not
externalizable) and defines a conformant readObject method.
Returns true if represented class is serializable (but not
externalizable) and defines a conformant readObject method. Otherwise,
returns false.
pack-private boolean
hasReadObjectNoDataMethod
()
Returns true if represented class is serializable (but not
externalizable) and defines a conformant readObjectNoData method.
Returns true if represented class is serializable (but not
externalizable) and defines a conformant readObjectNoData method.
Otherwise, returns false.
pack-private boolean
hasReadResolveMethod
()
Returns true if represented class is serializable or externalizable and
defines a conformant readResolve method.
Returns true if represented class is serializable or externalizable and
defines a conformant readResolve method. Otherwise, returns false.
pack-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.
pack-private boolean
hasWriteObjectMethod
()
Returns true if represented class is serializable (but not
externalizable) and defines a conformant writeObject method.
Returns true if represented class is serializable (but not
externalizable) and defines a conformant writeObject method. Otherwise,
returns false.
pack-private boolean
hasWriteReplaceMethod
()
Returns true if represented class is serializable or externalizable and
defines a conformant writeReplace method.
Returns true if represented class is serializable or externalizable and
defines a conformant writeReplace method. Otherwise, returns false.
pack-private void
invokeReadObject
(
Object obj,
ObjectInputStream in)
throws
ClassNotFoundException
IOException
UnsupportedOperationException
Invokes the readObject method of the represented serializable class.
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.
pack-private void
invokeReadObjectNoData
(
Object obj)
throws
IOException
UnsupportedOperationException
Invokes the readObjectNoData method of the represented serializable
class.
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.
pack-private Object
invokeReadResolve
(
Object obj)
throws
IOException
UnsupportedOperationException
Invokes the readResolve method of the represented serializable class and
returns the result.
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.
pack-private void
invokeWriteObject
(
Object obj,
ObjectOutputStream out)
throws
IOException
UnsupportedOperationException
Invokes the writeObject method of the represented serializable class.
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.
pack-private Object
invokeWriteReplace
(
Object obj)
throws
IOException
UnsupportedOperationException
Invokes the writeReplace method of the represented serializable class and
returns the result.
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.
pack-private boolean
isEnum
()
Returns true if class descriptor represents an enum type, false
otherwise.
pack-private boolean
isExternalizable
()
Returns true if represented class implements Externalizable, false
otherwise.
pack-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.
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.
pack-private boolean
isProxy
()
Returns true if class descriptor represents a dynamic proxy class, false
otherwise.
pack-private boolean
isSerializable
()
Returns true if represented class implements Serializable, false
otherwise.
publicstatic ObjectStreamClass
lookup
(
Class<
Object> cl)
Find the descriptor for a class that can be serialized.
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.
Returns:
the class descriptor for the specified class
Parameters:
-
cl - class for which to get the descriptor
pack-privatestatic 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.
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
publicstatic ObjectStreamClass
lookupAny
(
Class<
Object> cl)
Returns the descriptor for any class, regardless of whether it
implements
Serializable
.
Returns the descriptor for any class, regardless of whether it
implements
Serializable
.
Returns:
the class descriptor for the specified class
Parameters:
-
cl - class for which to get the descriptor
Since:
1.6
pack-private Object
newInstance
()
throws
InstantiationException
InvocationTargetException
UnsupportedOperationException
Creates a new instance of the represented class.
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.
pack-private void
readNonProxy
(
ObjectInputStream in)
throws
IOException
ClassNotFoundException
Reads non-proxy class descriptor information from given input stream.
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.
pack-private void
setObjFieldValues
(
Object obj,
Object vals)
Sets the serializable object fields of object obj using values from
array vals starting at offset 0.
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.
pack-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.
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.
public String
toString
()
Return a string describing this ObjectStreamClass.
pack-private void
writeNonProxy
(
ObjectOutputStream out)
throws
IOException
Writes non-proxy class descriptor information to given output stream.