Class ReflectionUtil

java.lang.Object
io.netty.util.internal.ReflectionUtil

public final class ReflectionUtil extends java.lang.Object
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static java.lang.Class<?>
    fail(java.lang.Class<?> type, java.lang.String typeParamName)
     
    private static java.lang.RuntimeException
    handleInaccessibleObjectException(java.lang.RuntimeException e)
     
    static java.lang.Class<?>
    resolveTypeParameter(java.lang.Object object, java.lang.Class<?> parametrizedSuperclass, java.lang.String typeParamName)
    Resolve a type parameter of a class that is a subclass of the given parametrized superclass.
    static java.lang.Throwable
    trySetAccessible(java.lang.reflect.AccessibleObject object, boolean checkAccessible)
    Try to call AccessibleObject.setAccessible(boolean) but will catch any SecurityException and
    invalid reference
    java.lang.reflect.InaccessibleObjectException
    and return it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReflectionUtil

      private ReflectionUtil()
  • Method Details

    • trySetAccessible

      public static java.lang.Throwable trySetAccessible(java.lang.reflect.AccessibleObject object, boolean checkAccessible)
      Try to call AccessibleObject.setAccessible(boolean) but will catch any SecurityException and
      invalid reference
      java.lang.reflect.InaccessibleObjectException
      and return it. The caller must check if it returns null and if not handle the returned exception.
    • handleInaccessibleObjectException

      private static java.lang.RuntimeException handleInaccessibleObjectException(java.lang.RuntimeException e)
    • fail

      private static java.lang.Class<?> fail(java.lang.Class<?> type, java.lang.String typeParamName)
    • resolveTypeParameter

      public static java.lang.Class<?> resolveTypeParameter(java.lang.Object object, java.lang.Class<?> parametrizedSuperclass, java.lang.String typeParamName)
      Resolve a type parameter of a class that is a subclass of the given parametrized superclass.
      Parameters:
      object - The object to resolve the type parameter for
      parametrizedSuperclass - The parametrized superclass
      typeParamName - The name of the type parameter to resolve
      Returns:
      The resolved type parameter
      Throws:
      java.lang.IllegalStateException - if the type parameter could not be resolved