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 .