Package: org.codehaus.groovy.reflection

## [Java] Class ReflectionUtils

- org.codehaus.groovy.reflection.ReflectionUtils

-     @SuppressWarnings("rawtypes")
      public class ReflectionUtils
      extends Object

  This class contains utility methods to determine which class called the current class to multiple levels of depth. Calls used to handle the groovy MOP are excluded from the level counting.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static boolean` | `checkAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess)`
    `` | `public static boolean` | `checkCanSetAccessible(AccessibleObject accessibleObject, Class<?> caller)`
    `` | `public static Class` | `getCallingClass()` Gets the immediate calling class, ignoring MOP frames.
    `` | `public static Class` | `getCallingClass(int matchLevel)` Gets the called that is matchLevel stack frames before the call, ignoring MOP frames.
    `` | `public static Class` | `getCallingClass(int matchLevel, Collection<String> extraIgnoredPackages)` Gets the called that is matchLevel stack frames before the call, ignoring MOP frames and desired exclude packages.
    `` | `public static List<Method>` | `getDeclaredMethods(Class<?> type, String name, Class<?> parameterTypes)`
    `` | `public static List<Method>` | `getMethods(Class<?> type, String name, Class<?> parameterTypes)`
    `` | `public static Class<?>[]` | `getPermittedSubclasses(Class<?> clazz)`
    `` | `public static boolean` | `isCallingClassReflectionAvailable()` Determines whether or not the getCallingClass methods will return any sensible results.
    `` | `public static boolean` | `isSealed(Class<?> clazz)`
    `` | `public static Optional<AccessibleObject>` | `makeAccessible(AccessibleObject ao)`
    `` | `public static AccessibleObject[]` | `makeAccessible(AccessibleObject[] aoa)`
    `` | `public static Optional<AccessibleObject>` | `makeAccessibleInPrivilegedAction(AccessibleObject ao)`
    `` | `public static boolean` | `parameterTypeMatches(Class<?>[] parameterTypes, Class<?>[] argTypes)`
    `` | `public static boolean` | `trySetAccessible(AccessibleObject ao)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Method Detail

    - #### public static boolean checkAccessible(Class<?> callerClass, Class<?> declaringClass, int memberModifiers, boolean allowIllegalAccess)

    - #### public static boolean checkCanSetAccessible(AccessibleObject accessibleObject, Class<?> caller)

    - #### public static Class getCallingClass()

      Gets the immediate calling class, ignoring MOP frames.

      Returns:
        The Class of the caller

    - #### public static Class getCallingClass(int matchLevel)

      Gets the called that is matchLevel stack frames before the call, ignoring MOP frames.

      Parameters:
        `matchLevel` - how may call stacks down to look. If it is less than 1 it is treated as though it was 1.
      Returns:
        The Class of the matched caller, or null if there aren't enough stackframes to satisfy matchLevel

    - #### public static Class getCallingClass(int matchLevel, Collection<String> extraIgnoredPackages)

      Gets the called that is matchLevel stack frames before the call, ignoring MOP frames and desired exclude packages.

      Parameters:
        `matchLevel` - how may call stacks down to look. If it is less than 1 it is treated as though it was 1.
        `extraIgnoredPackages` - A collection of string names of packages to exclude in addition to the MOP packages when counting stack frames.
      Returns:
        The Class of the matched caller, or null if there aren't enough stackframes to satisfy matchLevel

    - #### public static List<Method> getDeclaredMethods(Class<?> type, String name, Class<?> parameterTypes)

    - #### public static List<Method> getMethods(Class<?> type, String name, Class<?> parameterTypes)

    - #### public static Class<?>[] getPermittedSubclasses(Class<?> clazz)

    - #### public static boolean isCallingClassReflectionAvailable()

      Determines whether or not the getCallingClass methods will return any sensible results. On JVMs that are not Sun derived i.e. (gcj, Harmony) this will likely return false. When not available all getCallingClass methods will return null.

      Returns:
        true if getCallingClass can return anything but null, false if it will only return null.

    - #### public static boolean isSealed(Class<?> clazz)

    - #### @SuppressWarnings("deprecation") public static Optional<AccessibleObject> makeAccessible(AccessibleObject ao)

    - #### public static AccessibleObject[] makeAccessible(AccessibleObject[] aoa)

    - #### @SuppressWarnings("removal") public static Optional<AccessibleObject> makeAccessibleInPrivilegedAction(AccessibleObject ao)

    - #### public static boolean parameterTypeMatches(Class<?>[] parameterTypes, Class<?>[] argTypes)

    - #### public static boolean trySetAccessible(AccessibleObject ao)