invokeMethod

open fun invokeMethod(@NonNull clazz: Class<out Any>, @Nullable instance: Any, @NonNull methodName: String, args: Array<Any>): Any

Attempts to find and invoke the method matching the specified arguments Please note that this does not cache the lookup result, so if you need to call this many times you should do it manually and cache the Method to improve performance drastically

Return

The result of invoking the method

Parameters

clazz

The class holding the method

instance

The instance of the class to invoke the method on or null to invoke static method

methodName

The name of the method

args

The arguments to invoke the method with. arguments [ "hello", 12 ] would match someMethod(String s, int i)

Throws

No such method found

This method is inaccessible

An exception occurred while invoking this method


open fun invokeMethod(@NonNull instance: Any, @NonNull methodName: String, args: Array<Any>): Any

Attempts to find and invoke the method matching the specified arguments Please note that this does not cache the lookup result, so if you need to call this many times you should do it manually and cache the Method to improve performance drastically

Return

The result of invoking the method

Parameters

instance

The instance of the class to invoke the method on

methodName

The name of the method

args

The arguments to invoke the method with. arguments [ "hello", 12 ] would match someMethod(String s, int i)

Throws

No such method found

This method is inaccessible

An exception occurred while invoking this method