Package com.sun.corba.ee.impl.io
Class ObjectStreamClass
- java.lang.Object
-
- com.sun.corba.ee.impl.io.ObjectStreamClass
-
- All Implemented Interfaces:
java.io.Serializable
public class ObjectStreamClass extends java.lang.Object implements java.io.Serializable
A ObjectStreamClass describes a class that can be serialized to a stream or a class that was serialized to a stream. It contains the name and the serialVersionUID of the class.
The ObjectStreamClass for a specific class loaded in this Java VM can be found using the lookup method.- Since:
- JDK1.1
- Version:
- ObjectStreamClass.java 1.17 99/06/07
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ObjectStreamClass.CompareClassByName
private static class
ObjectStreamClass.CompareMemberByName
private static class
ObjectStreamClass.CompareObjStrFieldsByName
private static class
ObjectStreamClass.MethodSignature
private static class
ObjectStreamClass.PersistentFieldsValue
-
Field Summary
Fields Modifier and Type Field Description private long
actualSuid
private java.lang.String
actualSuidStr
private static org.glassfish.pfl.basic.reflection.Bridge
bridge
static int
CLASS_MASK
private static java.util.Comparator<java.lang.Class<?>>
compareClassByName
private static java.util.Comparator<java.lang.reflect.Member>
compareMemberByName
private static java.util.Comparator<ObjectStreamField>
compareObjStrFieldsByName
Comparator for ObjectStreamFields by nameprivate java.lang.reflect.Constructor<?>
cons
private static boolean
DEBUG_SVUID
private static org.glassfish.pfl.basic.concurrent.SoftCache<java.lang.Class<?>,ObjectStreamClass>
descriptorFor
private boolean
externalizable
static int
FIELD_MASK
private ObjectStreamField[]
fields
(package private) boolean
forProxyClass
private boolean
hasExternalizableBlockData
private boolean
initialized
Flag indicating whether or not this instance has successfully completed initialization.private boolean
isEnum
static long
kDefaultUID
private java.lang.Object
lock
static int
METHOD_MASK
private java.lang.String
name
static ObjectStreamField[]
NO_FIELDS
Set serialPersistentFields of a Serializable class to this value to denote that the class has no Serializable fields.(package private) int
objFields
private java.lang.Class<?>
ofClass
private static ObjectStreamClass.PersistentFieldsValue
persistentFieldsValue
(package private) int
primBytes
private java.lang.invoke.MethodHandle
readObjectMethod
private java.lang.invoke.MethodHandle
readResolveObjectMethod
private java.lang.String
rmiiiopOptionalDataRepId
Beginning in Java to IDL ptc/02-01-12, RMI-IIOP has a stream format version 2 which puts a fake valuetype around a Serializable's optional custom data.private boolean
serializable
private static long
serialVersionUID
use serialVersionUID from JDK 1.1.private long
suid
private java.lang.String
suidStr
private ObjectStreamClass
superclass
private java.lang.invoke.MethodHandle
writeObjectMethod
private java.lang.invoke.MethodHandle
writeReplaceObjectMethod
-
Constructor Summary
Constructors Modifier Constructor Description private
ObjectStreamClass(java.lang.Class<?> cl, ObjectStreamClass superdesc, boolean serial, boolean extern)
(package private)
ObjectStreamClass(java.lang.String n, long s)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static long
_computeSerialVersionUID(java.lang.Class<?> cl)
(package private) static boolean
compareClassNames(java.lang.String streamName, java.lang.String localName, char pkgSeparator)
private void
computeFieldInfo()
private java.lang.String
computeRMIIIOPOptionalDataRepId()
Java to IDL ptc-02-01-12 1.5.1 "The rep_id string passed to the start_value method must be 'RMI:org.omg.custom.class:hashcode:suid' where class is the fully-qualified name of the class whose writeObject method is being invoked and hashcode and suid are the class's hashcode and SUID."private static long
computeStructuralUID(ObjectStreamClass osc, java.lang.Class<?> cl)
java.lang.Class<?>
forClass()
Return the class in the local VM that this version is mapped to.long
getActualSerialVersionUID()
Return the actual (computed) serialVersionUID for this class.static long
getActualSerialVersionUID(java.lang.Class<?> clazz)
Return the actual (computed) serialVersionUID for this class.java.lang.String
getActualSerialVersionUIDStr()
Return the actual (computed) serialVersionUID for this class.ObjectStreamField
getField(java.lang.String name)
Get the field of this class by name.ObjectStreamField[]
getFields()
Return an array of the fields of this serializable class.(package private) ObjectStreamField[]
getFieldsNoCopy()
java.lang.String
getName()
The name of the class described by this descriptor.(package private) java.lang.invoke.MethodHandle
getReadObjectMethod()
java.lang.String
getRMIIIOPOptionalDataRepId()
This will return null if there is no writeObject method.long
getSerialVersionUID()
Return the serialVersionUID for this class.static long
getSerialVersionUID(java.lang.Class<?> clazz)
Return the serialVersionUID for this class.java.lang.String
getSerialVersionUIDStr()
Return the serialVersionUID string for this class.(package private) static java.lang.String
getSignature(java.lang.Class<?> clazz)
Compute the JVM signature for the class.(package private) static java.lang.String
getSignature(java.lang.reflect.Constructor<?> cons)
(package private) static java.lang.String
getSignature(java.lang.reflect.Method meth)
(package private) ObjectStreamClass
getSuperclass()
(package private) java.lang.invoke.MethodHandle
getWriteObjectMethod()
(package private) boolean
hasExternalizableBlockDataMode()
boolean
hasField(ValueMember field)
(package private) boolean
hasReadObject()
Return whether the class has a readObject method(package private) boolean
hasWriteObject()
private void
init()
(package private) boolean
isCustomMarshaled()
Returns when or not this class should be custom marshaled (use chunking).(package private) boolean
isExternalizable()
(package private) boolean
isNonSerializable()
(package private) boolean
isSerializable()
(package private) static ObjectStreamClass
lookup(java.lang.Class<?> cl)
Find the descriptor for a class that can be serialized.(package private) static ObjectStreamClass
lookupInternal(java.lang.Class<?> cl)
private static void
msg(java.lang.String str)
(package private) java.lang.Object
newInstance()
Creates a new instance of the represented class.java.lang.Object
readResolve(java.lang.Object value)
(package private) void
setSuperclass(ObjectStreamClass s)
java.lang.String
toString()
Return a string describing this ObjectStreamClass.static ObjectStreamField[]
translateFields(java.io.ObjectStreamField[] fields)
(package private) boolean
typeEquals(ObjectStreamClass other)
java.io.Serializable
writeReplace(java.io.Serializable value)
-
-
-
Field Detail
-
DEBUG_SVUID
private static final boolean DEBUG_SVUID
- See Also:
- Constant Field Values
-
kDefaultUID
public static final long kDefaultUID
- See Also:
- Constant Field Values
-
isEnum
private boolean isEnum
-
bridge
private static final org.glassfish.pfl.basic.reflection.Bridge bridge
-
persistentFieldsValue
private static final ObjectStreamClass.PersistentFieldsValue persistentFieldsValue
-
CLASS_MASK
public static final int CLASS_MASK
- See Also:
- Constant Field Values
-
FIELD_MASK
public static final int FIELD_MASK
- See Also:
- Constant Field Values
-
METHOD_MASK
public static final int METHOD_MASK
- See Also:
- Constant Field Values
-
descriptorFor
private static final org.glassfish.pfl.basic.concurrent.SoftCache<java.lang.Class<?>,ObjectStreamClass> descriptorFor
-
name
private java.lang.String name
-
superclass
private ObjectStreamClass superclass
-
serializable
private boolean serializable
-
externalizable
private boolean externalizable
-
fields
private ObjectStreamField[] fields
-
ofClass
private java.lang.Class<?> ofClass
-
forProxyClass
boolean forProxyClass
-
suid
private long suid
-
suidStr
private java.lang.String suidStr
-
actualSuid
private long actualSuid
-
actualSuidStr
private java.lang.String actualSuidStr
-
primBytes
int primBytes
-
objFields
int objFields
-
initialized
private boolean initialized
Flag indicating whether or not this instance has successfully completed initialization. This is to try to fix bug 4373844. Working to move to reusing java.io.ObjectStreamClass for JDK 1.5.
-
lock
private final java.lang.Object lock
-
hasExternalizableBlockData
private boolean hasExternalizableBlockData
-
writeObjectMethod
private java.lang.invoke.MethodHandle writeObjectMethod
-
readObjectMethod
private java.lang.invoke.MethodHandle readObjectMethod
-
writeReplaceObjectMethod
private transient java.lang.invoke.MethodHandle writeReplaceObjectMethod
-
readResolveObjectMethod
private transient java.lang.invoke.MethodHandle readResolveObjectMethod
-
cons
private java.lang.reflect.Constructor<?> cons
-
rmiiiopOptionalDataRepId
private java.lang.String rmiiiopOptionalDataRepId
Beginning in Java to IDL ptc/02-01-12, RMI-IIOP has a stream format version 2 which puts a fake valuetype around a Serializable's optional custom data. This valuetype has a special repository ID made from the Serializable's information which we are pre-computing and storing here.
-
serialVersionUID
private static final long serialVersionUID
use serialVersionUID from JDK 1.1. for interoperability- See Also:
- Constant Field Values
-
NO_FIELDS
public static final ObjectStreamField[] NO_FIELDS
Set serialPersistentFields of a Serializable class to this value to denote that the class has no Serializable fields.
-
compareClassByName
private static java.util.Comparator<java.lang.Class<?>> compareClassByName
-
compareObjStrFieldsByName
private static final java.util.Comparator<ObjectStreamField> compareObjStrFieldsByName
Comparator for ObjectStreamFields by name
-
compareMemberByName
private static java.util.Comparator<java.lang.reflect.Member> compareMemberByName
-
-
Constructor Detail
-
ObjectStreamClass
private ObjectStreamClass(java.lang.Class<?> cl, ObjectStreamClass superdesc, boolean serial, boolean extern)
-
ObjectStreamClass
ObjectStreamClass(java.lang.String n, long s)
-
-
Method Detail
-
lookup
static final ObjectStreamClass lookup(java.lang.Class<?> cl)
Find the descriptor for a class that can be serialized. Null is returned if the specified class does not implement java.io.Serializable or java.io.Externalizable.
-
lookupInternal
static ObjectStreamClass lookupInternal(java.lang.Class<?> cl)
-
getName
public final java.lang.String getName()
The name of the class described by this descriptor.- Returns:
- name of class
-
getSerialVersionUID
public static final long getSerialVersionUID(java.lang.Class<?> clazz)
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.- Parameters:
clazz
- class to get UID of- Returns:
- UID for the class
-
getSerialVersionUID
public final long getSerialVersionUID()
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.- Returns:
- SerialVersionUID for this class.
-
getSerialVersionUIDStr
public final java.lang.String getSerialVersionUIDStr()
Return the serialVersionUID string 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.- Returns:
- UID for this class
-
getActualSerialVersionUID
public static final long getActualSerialVersionUID(java.lang.Class<?> clazz)
Return the actual (computed) serialVersionUID for this class.- Parameters:
clazz
- Class to get UID of- Returns:
- The class UID
-
getActualSerialVersionUID
public final long getActualSerialVersionUID()
Return the actual (computed) serialVersionUID for this class.- Returns:
- UID for this class
-
getActualSerialVersionUIDStr
public final java.lang.String getActualSerialVersionUIDStr()
Return the actual (computed) serialVersionUID for this class.- Returns:
- UID for this class
-
forClass
public final java.lang.Class<?> forClass()
Return the class in the local VM that this version is mapped to. Null is returned if there is no corresponding local class.- Returns:
- Class this is mapped to
-
getFields
public ObjectStreamField[] getFields()
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:
- JDK1.2
-
hasField
public boolean hasField(ValueMember field)
-
getFieldsNoCopy
final ObjectStreamField[] getFieldsNoCopy()
-
getField
public final ObjectStreamField getField(java.lang.String name)
Get the field of this class by name.- Parameters:
name
- name of the field to get- Returns:
- The ObjectStreamField object of the named field or null if there is no such named field.
-
writeReplace
public java.io.Serializable writeReplace(java.io.Serializable value)
-
readResolve
public java.lang.Object readResolve(java.lang.Object value)
-
toString
public final java.lang.String toString()
Return a string describing this ObjectStreamClass.- Overrides:
toString
in classjava.lang.Object
-
getWriteObjectMethod
java.lang.invoke.MethodHandle getWriteObjectMethod()
-
getReadObjectMethod
java.lang.invoke.MethodHandle getReadObjectMethod()
-
init
private void init()
-
computeRMIIIOPOptionalDataRepId
private java.lang.String computeRMIIIOPOptionalDataRepId()
Java to IDL ptc-02-01-12 1.5.1 "The rep_id string passed to the start_value method must be 'RMI:org.omg.custom.class:hashcode:suid' where class is the fully-qualified name of the class whose writeObject method is being invoked and hashcode and suid are the class's hashcode and SUID."
-
getRMIIIOPOptionalDataRepId
public final java.lang.String getRMIIIOPOptionalDataRepId()
This will return null if there is no writeObject method.- Returns:
- A Serializable's optional custom data fake repository ID.
-
translateFields
public static final ObjectStreamField[] translateFields(java.io.ObjectStreamField[] fields)
-
compareClassNames
static boolean compareClassNames(java.lang.String streamName, java.lang.String localName, char pkgSeparator)
-
typeEquals
final boolean typeEquals(ObjectStreamClass other)
-
setSuperclass
final void setSuperclass(ObjectStreamClass s)
-
getSuperclass
final ObjectStreamClass getSuperclass()
-
hasReadObject
final boolean hasReadObject()
Return whether the class has a readObject method
-
hasWriteObject
final boolean hasWriteObject()
-
isCustomMarshaled
final boolean isCustomMarshaled()
Returns when or not this class should be custom marshaled (use chunking). This should happen if it is Externalizable OR if it or any of its superclasses has a writeObject method,
-
hasExternalizableBlockDataMode
boolean hasExternalizableBlockDataMode()
-
newInstance
java.lang.Object newInstance() throws java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.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.- Throws:
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
java.lang.UnsupportedOperationException
-
isSerializable
boolean isSerializable()
-
isExternalizable
boolean isExternalizable()
-
isNonSerializable
boolean isNonSerializable()
-
computeFieldInfo
private void computeFieldInfo()
-
msg
private static void msg(java.lang.String str)
-
_computeSerialVersionUID
private static long _computeSerialVersionUID(java.lang.Class<?> cl)
-
computeStructuralUID
private static long computeStructuralUID(ObjectStreamClass osc, java.lang.Class<?> cl)
-
getSignature
static java.lang.String getSignature(java.lang.Class<?> clazz)
Compute the JVM signature for the class.
-
getSignature
static java.lang.String getSignature(java.lang.reflect.Method meth)
-
getSignature
static java.lang.String getSignature(java.lang.reflect.Constructor<?> cons)
-
-