Package org.jboss.marshalling.reflect
Class SerializableClass
- java.lang.Object
-
- org.jboss.marshalling.reflect.SerializableClass
-
public final class SerializableClass extends java.lang.Object
Reflection information about a serializable class. Intended for use by implementations of the Marshalling API.
-
-
Field Summary
Fields Modifier and Type Field Description private long
effectiveSerialVersionUID
private SerializableField[]
fields
private java.util.Map<java.lang.String,SerializableField>
fieldsByName
private static java.util.Comparator<? super SerializableField>
NAME_COMPARATOR
private java.lang.reflect.Constructor<?>
noArgConstructor
static SerializableField[]
NOFIELDS
An empty array of fields.private java.lang.reflect.Constructor<?>
nonInitConstructor
private java.lang.reflect.Constructor<?>
objectInputConstructor
private java.lang.reflect.Method
readObject
private java.lang.reflect.Method
readObjectNoData
private java.lang.reflect.Method
readResolve
private static sun.reflect.ReflectionFactory
reflectionFactory
private java.lang.Class<?>
subject
private java.lang.reflect.Method
writeObject
private java.lang.reflect.Method
writeReplace
-
Constructor Summary
Constructors Constructor Description SerializableClass(java.lang.Class<?> subject)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
callNoArgConstructor()
Invoke the public no-arg constructor on this class.java.lang.Object
callNonInitConstructor()
Invoke the non-init constructor on this class.java.lang.Object
callObjectInputConstructor(java.io.ObjectInput objectInput)
Invoke the public constructor accepting an ObjectInput.void
callReadObject(java.lang.Object object, java.io.ObjectInputStream inputStream)
Invoke thereadObject()
method for an object.void
callReadObjectNoData(java.lang.Object object)
Invoke thereadObjectNoData()
method for an object.java.lang.Object
callReadResolve(java.lang.Object object)
Invoke thereadResolve()
method for an object.void
callWriteObject(java.lang.Object object, java.io.ObjectOutputStream outputStream)
Invoke thewriteObject()
method for an object.java.lang.Object
callWriteReplace(java.lang.Object object)
Invoke thewriteReplace()
method for an object.private static java.io.ObjectStreamField[]
getDeclaredSerialPersistentFields(java.lang.Class<?> clazz)
long
getEffectiveSerialVersionUID()
Get the effective serial version UID of this class.SerializableField[]
getFields()
Get the serializable fields of this class.(package private) <T> java.lang.reflect.Constructor<T>
getNoArgConstructor()
(package private) <T> java.lang.reflect.Constructor<T>
getNoInitConstructor()
SerializableField
getSerializableField(java.lang.String name, java.lang.Class<?> fieldType, boolean unshared)
Create a synthetic field for this object class.private static SerializableField[]
getSerializableFields(java.lang.Class<?> clazz)
java.lang.Class<?>
getSubjectClass()
Get theClass
of this class.boolean
hasNoArgConstructor()
Determine whether this class has a public no-arg constructor.boolean
hasNoInitConstructor()
Determine whether this class has a non-init constructor.boolean
hasObjectInputConstructor()
Determine whether this class has a public constructor accepting an ObjectInput.boolean
hasReadObject()
Determine whether this class has areadObject()
method.boolean
hasReadObjectNoData()
Determine whether this class has areadObjectNoData()
method.boolean
hasReadResolve()
Determine whether this class has areadResolve()
method.boolean
hasWriteObject()
Determine whether this class has awriteObject()
method.boolean
hasWriteReplace()
Determine whether this class has awriteReplace()
method.private static java.lang.Object
invokeConstructor(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args)
private static java.lang.Object
invokeConstructorNoException(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args)
private static <T> java.lang.reflect.Constructor<T>
lookupNonInitConstructor(java.lang.Class<T> subject)
java.lang.String
toString()
-
-
-
Field Detail
-
reflectionFactory
private static final sun.reflect.ReflectionFactory reflectionFactory
-
subject
private final java.lang.Class<?> subject
-
writeObject
private final java.lang.reflect.Method writeObject
-
writeReplace
private final java.lang.reflect.Method writeReplace
-
readObject
private final java.lang.reflect.Method readObject
-
readObjectNoData
private final java.lang.reflect.Method readObjectNoData
-
readResolve
private final java.lang.reflect.Method readResolve
-
noArgConstructor
private final java.lang.reflect.Constructor<?> noArgConstructor
-
objectInputConstructor
private final java.lang.reflect.Constructor<?> objectInputConstructor
-
nonInitConstructor
private final java.lang.reflect.Constructor<?> nonInitConstructor
-
fields
private final SerializableField[] fields
-
fieldsByName
private final java.util.Map<java.lang.String,SerializableField> fieldsByName
-
effectiveSerialVersionUID
private final long effectiveSerialVersionUID
-
NAME_COMPARATOR
private static final java.util.Comparator<? super SerializableField> NAME_COMPARATOR
-
NOFIELDS
public static final SerializableField[] NOFIELDS
An empty array of fields.
-
-
Method Detail
-
getSerializableFields
private static SerializableField[] getSerializableFields(java.lang.Class<?> clazz)
-
getDeclaredSerialPersistentFields
private static java.io.ObjectStreamField[] getDeclaredSerialPersistentFields(java.lang.Class<?> clazz)
-
getFields
public SerializableField[] getFields()
Get the serializable fields of this class. The returned array is a direct reference, so care should be taken not to modify it.- Returns:
- the fields
-
getSerializableField
public SerializableField getSerializableField(java.lang.String name, java.lang.Class<?> fieldType, boolean unshared) throws java.lang.ClassNotFoundException
Create a synthetic field for this object class.- Parameters:
name
- the name of the fieldfieldType
- the field typeunshared
-true
if the field should be unshared- Returns:
- the field
- Throws:
java.lang.ClassNotFoundException
- if a class was not found while looking up the subject class
-
hasWriteObject
public boolean hasWriteObject()
Determine whether this class has awriteObject()
method.- Returns:
true
if there is awriteObject()
method
-
callWriteObject
public void callWriteObject(java.lang.Object object, java.io.ObjectOutputStream outputStream) throws java.io.IOException
Invoke thewriteObject()
method for an object.- Parameters:
object
- the object to invoke onoutputStream
- the object output stream to pass in- Throws:
java.io.IOException
- if an I/O error occurs
-
hasReadObject
public boolean hasReadObject()
Determine whether this class has areadObject()
method.- Returns:
true
if there is areadObject()
method
-
callReadObject
public void callReadObject(java.lang.Object object, java.io.ObjectInputStream inputStream) throws java.io.IOException, java.lang.ClassNotFoundException
Invoke thereadObject()
method for an object.- Parameters:
object
- the object to invoke oninputStream
- the object input stream to pass in- Throws:
java.io.IOException
- if an I/O error occursjava.lang.ClassNotFoundException
- if a class was not able to be loaded
-
hasReadObjectNoData
public boolean hasReadObjectNoData()
Determine whether this class has areadObjectNoData()
method.- Returns:
true
if there is areadObjectNoData()
method
-
callReadObjectNoData
public void callReadObjectNoData(java.lang.Object object) throws java.io.ObjectStreamException
Invoke thereadObjectNoData()
method for an object.- Parameters:
object
- the object to invoke on- Throws:
java.io.ObjectStreamException
- if an I/O error occurs
-
hasWriteReplace
public boolean hasWriteReplace()
Determine whether this class has awriteReplace()
method.- Returns:
true
if there is awriteReplace()
method
-
callWriteReplace
public java.lang.Object callWriteReplace(java.lang.Object object) throws java.io.ObjectStreamException
Invoke thewriteReplace()
method for an object.- Parameters:
object
- the object to invoke on- Returns:
- the nominated replacement object
- Throws:
java.io.ObjectStreamException
- if an I/O error occurs
-
hasReadResolve
public boolean hasReadResolve()
Determine whether this class has areadResolve()
method.- Returns:
true
if there is areadResolve()
method
-
callReadResolve
public java.lang.Object callReadResolve(java.lang.Object object) throws java.io.ObjectStreamException
Invoke thereadResolve()
method for an object.- Parameters:
object
- the object to invoke on- Returns:
- the original object
- Throws:
java.io.ObjectStreamException
- if an I/O error occurs
-
hasNoArgConstructor
public boolean hasNoArgConstructor()
Determine whether this class has a public no-arg constructor.- Returns:
true
if there is such a constructor
-
callNoArgConstructor
public java.lang.Object callNoArgConstructor() throws java.io.IOException
Invoke the public no-arg constructor on this class.- Returns:
- the new instance
- Throws:
java.io.IOException
- if an I/O error occurs
-
hasObjectInputConstructor
public boolean hasObjectInputConstructor()
Determine whether this class has a public constructor accepting an ObjectInput.- Returns:
true
if there is such a constructor
-
callObjectInputConstructor
public java.lang.Object callObjectInputConstructor(java.io.ObjectInput objectInput) throws java.io.IOException
Invoke the public constructor accepting an ObjectInput.- Parameters:
objectInput
- the ObjectInput to pass to the constructor- Returns:
- the new instance
- Throws:
java.io.IOException
- if an I/O error occurs
-
hasNoInitConstructor
public boolean hasNoInitConstructor()
Determine whether this class has a non-init constructor.- Returns:
- whether this class has a non-init constructor
-
callNonInitConstructor
public java.lang.Object callNonInitConstructor()
Invoke the non-init constructor on this class.- Returns:
- the new instance
-
invokeConstructor
private static java.lang.Object invokeConstructor(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args) throws java.io.IOException
- Throws:
java.io.IOException
-
invokeConstructorNoException
private static java.lang.Object invokeConstructorNoException(java.lang.reflect.Constructor<?> constructor, java.lang.Object... args)
-
getEffectiveSerialVersionUID
public long getEffectiveSerialVersionUID()
Get the effective serial version UID of this class.- Returns:
- the serial version UID
-
getSubjectClass
public java.lang.Class<?> getSubjectClass()
Get theClass
of this class.- Returns:
- the subject class
-
lookupNonInitConstructor
private static <T> java.lang.reflect.Constructor<T> lookupNonInitConstructor(java.lang.Class<T> subject)
-
getNoInitConstructor
<T> java.lang.reflect.Constructor<T> getNoInitConstructor()
-
getNoArgConstructor
<T> java.lang.reflect.Constructor<T> getNoArgConstructor()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-