接口 Invoker

所有已知子接口:
MethodAccessor
所有已知实现类:
MethodInvoker, ReflectiveMethodAccessor
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@FunctionalInterface public interface Invoker
作者:
TODAY 2019-10-18 22:35
  • 方法概要

    修饰符和类型
    方法
    说明
    invoke(Object obj, Object[] args)
    Invokes the underlying method represented by this Invoker object, on the specified object with the specified parameters.
  • 方法详细资料

    • invoke

      Object invoke(Object obj, Object[] args)
      Invokes the underlying method represented by this Invoker object, on the specified object with the specified parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary.

      If the underlying method is static, then the specified obj argument is ignored. It may be null.

      If the number of formal parameters required by the underlying method is 0, the supplied args array may be of length 0 or null.

      If the underlying method is static, the class that declared the method is initialized if it has not already been initialized.

      If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is first appropriately wrapped in an object. However, if the value has the type of array of a primitive type, the elements of the array are not wrapped in objects; in other words, an array of primitive type is returned. If the underlying method return type is void, the invocation returns null.

      参数:
      obj - the object the underlying method is invoked from
      args - the arguments used for the method call
      返回:
      the result of dispatching the method represented by this object on obj with parameters args
      抛出:
      NullPointerException - if the specified object is null and the method is an instance method.
      ExceptionInInitializerError - if the initialization provoked by this method fails.