FastInvoke

Utility class providing fast method invocation and object instantiation using Java reflection.

This class offers optimized methods for invoking methods and creating instances with improved exception handling. It avoids the performance overhead of the spread operator by using Object[] for method arguments, addressing the Detekt SpreadOperator rule.

All methods in this class are thread-safe and can be used concurrently.

Note: This class cannot be instantiated as it contains only static utility methods.

See also

Functions

Link copied to clipboard
open fun <T> invoke(@NotNull method: Method, target: Any, args: Array<Any>): T
Invokes the specified method on the target object with the given arguments.
Link copied to clipboard
@NotNull
open fun <T> newInstance(@NotNull constructor: Constructor<T>, args: Array<Any>): T
Creates a new instance of the class using the specified constructor with the given arguments.
Link copied to clipboard
open fun <T> safeInvoke(@NotNull method: Method, target: Any, args: Array<Any>): T
Safely invokes the specified method on the target object, unwrapping InvocationTargetException.
Link copied to clipboard
open fun <T> safeNewInstance(@NotNull constructor: Constructor<T>, args: Array<Any>): T
Safely creates a new instance of the class, unwrapping InvocationTargetException.