Class ReflectionUtil

java.lang.Object
org.spockframework.util.ReflectionUtil

public abstract class ReflectionUtil extends Object
  • Constructor Details

    • ReflectionUtil

      public ReflectionUtil()
  • Method Details

    • loadClassIfAvailable

      public static Class<?> loadClassIfAvailable(String className)
    • isClassAvailable

      public static boolean isClassAvailable(String className)
    • isMethodAvailable

      public static boolean isMethodAvailable(String className, String methodName)
    • isAnnotationPresent

      public static boolean isAnnotationPresent(AnnotatedElement element, String className)
    • getMethodByName

      public static Method getMethodByName(Class<?> clazz, String name)
      Finds a public method with the given name declared in the given class/interface or one of its super classes/interfaces. If multiple such methods exists, it is undefined which one is returned.
    • getDeclaredMethodByName

      public static Method getDeclaredMethodByName(Class<?> clazz, String name)
    • getMethodBySignature

      public static Method getMethodBySignature(Class<?> clazz, String name, Class<?>... parameterTypes)
    • getDeclaredMethodBySignature

      public static Method getDeclaredMethodBySignature(Class<?> clazz, String name, Class<?>... parameterTypes)
    • getClassFile

      public static File getClassFile(Class<?> clazz)
      Returns the class file for the given class (which has been verified to exist in the returned location), or null if the class file could not be found (e.g. because it is contained in a Jar).
    • getDefaultValue

      public static Object getDefaultValue(Class<?> type)
    • hasAnyOfTypes

      public static boolean hasAnyOfTypes(Object value, Class<?>... types)
    • getTypes

      public static Class[] getTypes(Object... objects)
    • invokeMethod

      public static Object invokeMethod(Object target, Method method, Object... args)