public static Runnable asRunnable (Object instance, String methodName)
    {
        Class<?> clazz = instance.getClass();
        Method method = findMethod(clazz, methodName);
        if (Modifier.isStatic(method.getModifiers())) {
            throw new IllegalArgumentException(
                clazz.getName() + "." + methodName + "() must not be static");
        }
        return new MethodRunner(method, instance);
    }
public static Runnable asRunnable ( Object instance , String methodName ) { Class < ? > clazz = instance . getClass ( ) ; Method method = findMethod ( clazz , methodName ) ; if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { throw new IllegalArgumentException ( clazz . getName ( ) + "." + methodName + "() must not be static" ) ; } return new MethodRunner ( method , instance ) ; }
Creates a runnable that invokes the specified method on the specified instance via
reflection.

<p> NOTE: if you specify a protected or private method this method will call {@link
Method#setAccessible} to make the method accessible. If you're writing secure code or need
to run in a sandbox, don't use this functionality.

@throws IllegalArgumentException if the supplied method name does not correspond to a
non-static zero-argument method of the supplied instance's class.