Package org.jboss.marshalling.reflect
Class SerializableClass
java.lang.Object
org.jboss.marshalling.reflect.SerializableClass
Reflection information about a serializable class. Intended for use by implementations of the Marshalling API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private final SerializableField[]
private final Map
<String, SerializableField> private static final Comparator
<? super SerializableField> private final Constructor
<?> static final SerializableField[]
An empty array of fields.private final Constructor
<?> private final Constructor
<?> private final Method
private final Method
private final Method
private static final sun.reflect.ReflectionFactory
private final Class
<?> private final Method
private final Method
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInvoke the public no-arg constructor on this class.Invoke the non-init constructor on this class.callObjectInputConstructor
(ObjectInput objectInput) Invoke the public constructor accepting an ObjectInput.void
callReadObject
(Object object, ObjectInputStream inputStream) Invoke thereadObject()
method for an object.void
callReadObjectNoData
(Object object) Invoke thereadObjectNoData()
method for an object.callReadResolve
(Object object) Invoke thereadResolve()
method for an object.void
callWriteObject
(Object object, ObjectOutputStream outputStream) Invoke thewriteObject()
method for an object.callWriteReplace
(Object object) Invoke thewriteReplace()
method for an object.private static ObjectStreamField[]
getDeclaredSerialPersistentFields
(Class<?> clazz) long
Get the effective serial version UID of this class.Get the serializable fields of this class.(package private) <T> Constructor
<T> (package private) <T> Constructor
<T> getSerializableField
(String name, Class<?> fieldType, boolean unshared) Create a synthetic field for this object class.private static SerializableField[]
getSerializableFields
(Class<?> clazz) Class
<?> Get theClass
of this class.boolean
Determine whether this class has a public no-arg constructor.boolean
Determine whether this class has a non-init constructor.boolean
Determine whether this class has a public constructor accepting an ObjectInput.boolean
Determine whether this class has areadObject()
method.boolean
Determine whether this class has areadObjectNoData()
method.boolean
Determine whether this class has areadResolve()
method.boolean
Determine whether this class has awriteObject()
method.boolean
Determine whether this class has awriteReplace()
method.private static Object
invokeConstructor
(Constructor<?> constructor, Object... args) private static Object
invokeConstructorNoException
(Constructor<?> constructor, Object... args) private static <T> Constructor
<T> lookupNonInitConstructor
(Class<T> subject) toString()
-
Field Details
-
reflectionFactory
private static final sun.reflect.ReflectionFactory reflectionFactory -
subject
-
writeObject
-
writeReplace
-
readObject
-
readObjectNoData
-
readResolve
-
noArgConstructor
-
objectInputConstructor
-
nonInitConstructor
-
fields
-
fieldsByName
-
effectiveSerialVersionUID
private final long effectiveSerialVersionUID -
NAME_COMPARATOR
-
NOFIELDS
An empty array of fields.
-
-
Constructor Details
-
SerializableClass
SerializableClass(Class<?> subject)
-
-
Method Details
-
getSerializableFields
-
getDeclaredSerialPersistentFields
-
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(String name, Class<?> fieldType, boolean unshared) throws 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:
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
Invoke thewriteObject()
method for an object.- Parameters:
object
- the object to invoke onoutputStream
- the object output stream to pass in- Throws:
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(Object object, ObjectInputStream inputStream) throws IOException, ClassNotFoundException Invoke thereadObject()
method for an object.- Parameters:
object
- the object to invoke oninputStream
- the object input stream to pass in- Throws:
IOException
- if an I/O error occursClassNotFoundException
- 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
Invoke thereadObjectNoData()
method for an object.- Parameters:
object
- the object to invoke on- Throws:
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
Invoke thewriteReplace()
method for an object.- Parameters:
object
- the object to invoke on- Returns:
- the nominated replacement object
- Throws:
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
Invoke thereadResolve()
method for an object.- Parameters:
object
- the object to invoke on- Returns:
- the original object
- Throws:
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
Invoke the public no-arg constructor on this class.- Returns:
- the new instance
- Throws:
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
Invoke the public constructor accepting an ObjectInput.- Parameters:
objectInput
- the ObjectInput to pass to the constructor- Returns:
- the new instance
- Throws:
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
Invoke the non-init constructor on this class.- Returns:
- the new instance
-
invokeConstructor
private static Object invokeConstructor(Constructor<?> constructor, Object... args) throws IOException - Throws:
IOException
-
invokeConstructorNoException
-
getEffectiveSerialVersionUID
public long getEffectiveSerialVersionUID()Get the effective serial version UID of this class.- Returns:
- the serial version UID
-
getSubjectClass
Get theClass
of this class.- Returns:
- the subject class
-
lookupNonInitConstructor
-
getNoInitConstructor
-
getNoArgConstructor
-
toString
-