Class SerializableClass

java.lang.Object
org.jboss.marshalling.reflect.SerializableClass

public final class SerializableClass extends Object
Reflection information about a serializable class. Intended for use by implementations of the Marshalling API.
  • Field Details

    • reflectionFactory

      private static final sun.reflect.ReflectionFactory reflectionFactory
    • subject

      private final Class<?> subject
    • writeObject

      private final Method writeObject
    • writeReplace

      private final Method writeReplace
    • readObject

      private final Method readObject
    • readObjectNoData

      private final Method readObjectNoData
    • readResolve

      private final Method readResolve
    • noArgConstructor

      private final Constructor<?> noArgConstructor
    • objectInputConstructor

      private final Constructor<?> objectInputConstructor
    • nonInitConstructor

      private final Constructor<?> nonInitConstructor
    • fields

      private final SerializableField[] fields
    • fieldsByName

      private final Map<String,SerializableField> fieldsByName
    • effectiveSerialVersionUID

      private final long effectiveSerialVersionUID
    • NAME_COMPARATOR

      private static final Comparator<? super SerializableField> NAME_COMPARATOR
    • NOFIELDS

      public static final SerializableField[] NOFIELDS
      An empty array of fields.
  • Constructor Details

    • SerializableClass

      SerializableClass(Class<?> subject)
  • Method Details

    • getSerializableFields

      private static SerializableField[] getSerializableFields(Class<?> clazz)
    • getDeclaredSerialPersistentFields

      private static ObjectStreamField[] getDeclaredSerialPersistentFields(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(String name, Class<?> fieldType, boolean unshared) throws ClassNotFoundException
      Create a synthetic field for this object class.
      Parameters:
      name - the name of the field
      fieldType - the field type
      unshared - 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 a writeObject() method.
      Returns:
      true if there is a writeObject() method
    • callWriteObject

      public void callWriteObject(Object object, ObjectOutputStream outputStream) throws IOException
      Invoke the writeObject() method for an object.
      Parameters:
      object - the object to invoke on
      outputStream - the object output stream to pass in
      Throws:
      IOException - if an I/O error occurs
    • hasReadObject

      public boolean hasReadObject()
      Determine whether this class has a readObject() method.
      Returns:
      true if there is a readObject() method
    • callReadObject

      public void callReadObject(Object object, ObjectInputStream inputStream) throws IOException, ClassNotFoundException
      Invoke the readObject() method for an object.
      Parameters:
      object - the object to invoke on
      inputStream - the object input stream to pass in
      Throws:
      IOException - if an I/O error occurs
      ClassNotFoundException - if a class was not able to be loaded
    • hasReadObjectNoData

      public boolean hasReadObjectNoData()
      Determine whether this class has a readObjectNoData() method.
      Returns:
      true if there is a readObjectNoData() method
    • callReadObjectNoData

      public void callReadObjectNoData(Object object) throws ObjectStreamException
      Invoke the readObjectNoData() 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 a writeReplace() method.
      Returns:
      true if there is a writeReplace() method
    • callWriteReplace

      public Object callWriteReplace(Object object) throws ObjectStreamException
      Invoke the writeReplace() 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 a readResolve() method.
      Returns:
      true if there is a readResolve() method
    • callReadResolve

      public Object callReadResolve(Object object) throws ObjectStreamException
      Invoke the readResolve() 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

      public Object callNoArgConstructor() throws IOException
      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

      public Object callObjectInputConstructor(ObjectInput objectInput) throws IOException
      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

      public Object 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

      private static Object invokeConstructorNoException(Constructor<?> constructor, Object... args)
    • getEffectiveSerialVersionUID

      public long getEffectiveSerialVersionUID()
      Get the effective serial version UID of this class.
      Returns:
      the serial version UID
    • getSubjectClass

      public Class<?> getSubjectClass()
      Get the Class of this class.
      Returns:
      the subject class
    • lookupNonInitConstructor

      private static <T> Constructor<T> lookupNonInitConstructor(Class<T> subject)
    • getNoInitConstructor

      <T> Constructor<T> getNoInitConstructor()
    • getNoArgConstructor

      <T> Constructor<T> getNoArgConstructor()
    • toString

      public String toString()
      Overrides:
      toString in class Object