Class ReflectionUtils

java.lang.Object
org.apache.hadoop.util.ReflectionUtils

@Public @Evolving public class ReflectionUtils extends Object
General reflection utils
  • Constructor Details

    • ReflectionUtils

      public ReflectionUtils()
  • Method Details

    • setConf

      public static void setConf(Object theObject, Configuration conf)
      Check and set 'configuration' if necessary.
      Parameters:
      theObject - object for which to set configuration
      conf - Configuration
    • newInstance

      public static <T> T newInstance(Class<T> theClass, Configuration conf)
      Create an object for the given class and initialize it from conf
      Type Parameters:
      T - Generics Type T.
      Parameters:
      theClass - class of which an object is created
      conf - Configuration
      Returns:
      a new object
    • newInstance

      public static <T> T newInstance(Class<T> theClass, Configuration conf, Class<?>[] argTypes, Object... values)
      Create an object for the given class and initialize it from conf
      Type Parameters:
      T - Generics Type.
      Parameters:
      theClass - class of which an object is created
      conf - Configuration
      argTypes - the types of the arguments
      values - the values of the arguments
      Returns:
      a new object
    • setContentionTracing

      public static void setContentionTracing(boolean val)
    • printThreadInfo

      public static void printThreadInfo(PrintStream stream, String title)
      Print all of the thread's information and stack traces.
      Parameters:
      stream - the stream to
      title - a string title for the stack trace
    • logThreadInfo

      @Deprecated public static void logThreadInfo(org.apache.commons.logging.Log log, String title, long minInterval)
      Deprecated.
      to be removed with 3.4.0. Use logThreadInfo(Logger, String, long) instead.
      Log the current thread stacks at INFO level.
      Parameters:
      log - the logger that logs the stack trace
      title - a descriptive title for the call stacks
      minInterval - the minimum time from the last
    • logThreadInfo

      public static void logThreadInfo(org.slf4j.Logger log, String title, long minInterval)
      Log the current thread stacks at INFO level.
      Parameters:
      log - the logger that logs the stack trace
      title - a descriptive title for the call stacks
      minInterval - the minimum time from the last
    • getClass

      public static <T> Class<T> getClass(T o)
      Return the correctly-typed Class of the given object.
      Type Parameters:
      T - Generics Type T.
      Parameters:
      o - object whose correctly-typed Class is to be obtained
      Returns:
      the correctly typed Class of the given object.
    • copy

      public static <T> T copy(Configuration conf, T src, T dst) throws IOException
      Make a copy of the writable object using serialization to a buffer.
      Type Parameters:
      T - Generics Type.
      Parameters:
      src - the object to copy from
      dst - the object to copy into, which is destroyed
      conf - configuration.
      Returns:
      dst param (the copy)
      Throws:
      IOException - raised on errors performing I/O.
    • cloneWritableInto

      @Deprecated public static void cloneWritableInto(Writable dst, Writable src) throws IOException
      Deprecated.
      Throws:
      IOException
    • getDeclaredFieldsIncludingInherited

      public static List<Field> getDeclaredFieldsIncludingInherited(Class<?> clazz)
      Gets all the declared fields of a class including fields declared in superclasses.
      Parameters:
      clazz - clazz
      Returns:
      field List
    • getDeclaredMethodsIncludingInherited

      public static List<Method> getDeclaredMethodsIncludingInherited(Class<?> clazz)
      Gets all the declared methods of a class including methods declared in superclasses.
      Parameters:
      clazz - clazz.
      Returns:
      Method List.