invoke

API文档内容
Invokes the underlying method represented by this Method 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 an instance method, it is invoked using dynamic method lookup as documented in The Java Language Specification, Second Edition, section 15.12.4.4; in particular, overriding based on the runtime type of the target object will occur.

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 an 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.
翻译
使用指定的参数在指定的对象上调用此Method对象表示的基础方法。单个参数会自动解包以匹配原始形式参数,并且必要时,原始参数和参考参数都会受方法调用转换的影响。

如果底层方法是静态的,那么指定的obj参数将被忽略。它可能为空。

如果底层方法所需的形式参数数量为0,则所提供的args数组可能长度为0或为空。

如果底层方法是实例方法,则使用动态方法查找来调用该方法,如“Java语言规范第二版”第15.12.4.4节中所述;特别是基于目标对象的运行时类型的覆盖将发生。

如果底层方法是静态的,那么声明该方法的类如果尚未初始化,则会被初始化。

如果方法正常完成,它返回的值将返回给invoke的调用者;如果该值具有基元类型,则首先将其适当包装在一个对象中。但是,如果该值具有基元类型数组的类型,则该数组的元素不会包含在对象中;换句话说,返回一个原始类型的数组。如果基础方法返回类型为void,则调用返回null。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

helloworddm

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值