Class SerializationReflectionHelper

java.lang.Object
org.jppf.serialization.SerializationReflectionHelper

public final class SerializationReflectionHelper extends Object
This helper class provides utility methods to facilitate the JPPF-sepcific serialization and deserilaization.
Author:
Laurent Cohen
  • Constructor Details

    • SerializationReflectionHelper

      public SerializationReflectionHelper()
  • Method Details

    • getPersistentDeclaredFields

      public static org.jppf.serialization.FieldDescriptor[] getPersistentDeclaredFields(Class<?> clazz) throws Exception
      Get all declared non-transient and non-static fields of the given class.
      Parameters:
      clazz - the class object from which to extract the fields.
      Returns:
      an array of FieldDescriptor objects.
      Throws:
      Exception - if any error occurs.
    • getSignatureFromType

      public static String getSignatureFromType(Class<?> clazz) throws Exception
      Get a unique string representation for the specified type.
      Parameters:
      clazz - the type from which to get the signature.
      Returns:
      a string representing the type.
      Throws:
      Exception - if any error occurs.
    • getTypeFromSignature

      public static Class<?> getTypeFromSignature(String signature, ClassLoader cl) throws Exception
      Lookup or load the non-array class based on the specified signature.
      Parameters:
      signature - the class signature.
      cl - the class loader used to load the class.
      Returns:
      a Class object.
      Throws:
      Exception - if any error occurs.
    • getNonArrayTypeFromSignature

      public static Class<?> getNonArrayTypeFromSignature(String signature, ClassLoader cl) throws Exception
      Lookup or load the non-array class based on the specified signature.
      Parameters:
      signature - the class signature.
      cl - the class loader used to load the class.
      Returns:
      a Class object.
      Throws:
      Exception - if any error occurs.
    • create

      public static Object create(Class<?> clazz) throws Exception
      Create an object without calling any of its class constructors if the JVM supports it, or failing that, attempt to call the constructor with the smallest possible number of arguments.
      Parameters:
      clazz - the object's class.
      Returns:
      the newly created object.
      Throws:
      Exception - if any error occurs.
    • createString

      public static String createString(char[] chars) throws Exception
      Create a string from the specified array of characters.
      Parameters:
      chars - the string's value.
      Returns:
      a new string with the specified characters.
      Throws:
      Exception - if any error occurs.
    • getStringValue

      public static char[] getStringValue(String s) throws Exception
      Get the chars in a string without copying the array.
      Parameters:
      s - the string to get the chars from.
      Returns:
      an array of chars.
      Throws:
      Exception - if any error occurs.