mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-04 09:45:19 +08:00
Fix ConstructorFinder bug when the params set to nothing will got NoSuchMethodError
This commit is contained in:
@@ -742,7 +742,7 @@ method {
|
||||
|
||||
#### 必要的查询条件
|
||||
|
||||
!> 在方法、构造方法查询条件中,<u>**即使是无参的方法也需要设置查询条件**</u>。
|
||||
!> 在普通方法查询条件中,<u>**即使是无参的方法也需要设置查询条件**</u>。
|
||||
|
||||
假设我们有如下的 `Class`。
|
||||
|
||||
@@ -793,7 +793,44 @@ TestFoo::class.java.method {
|
||||
|
||||
至此,上述的示例将可以完美地匹配到 `public void foo()` 方法。
|
||||
|
||||
> PS:在较旧的 API 版本中是允许匹配不写默认匹配无参方法的做法的,但是最新版本更正了这一问题,请确保你使用的是最新版本的 API。
|
||||
> PS:在较旧的 API 版本中是允许匹配不写默认匹配无参方法的做法的,但是最新版本更正了这一问题,请确保你使用的是最新的 API 版本。
|
||||
|
||||
#### 可简写查询条件
|
||||
|
||||
> 在构造方法查询条件中,<u>**无参的构造方法可以不需要填写查询条件**</u>。
|
||||
|
||||
假设我们有如下的 `Class`。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```java
|
||||
public class TestFoo {
|
||||
|
||||
public TestFoo() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
我们要得到其中的 `public TestFoo()` 构造方法,可以写作如下形式。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
TestFoo::class.java.constructor { emptyParam() }
|
||||
```
|
||||
|
||||
上面的例子可以成功获取到 `public TestFoo()` 构造方法,但是感觉有一些繁琐。
|
||||
|
||||
与普通方法不同,由于构造方法不需要考虑 `name` 名称,当构造方法没有参数的时候,我们可以省略 `emptyParam` 参数。
|
||||
|
||||
> 示例如下
|
||||
|
||||
```kotlin
|
||||
TestFoo::class.java.constructor()
|
||||
```
|
||||
|
||||
!> PS:在旧的 API 版本中构造方法不填写任何查询参数会直接找不到构造方法,<u>**这是一个 BUG,最新版本已经进行修复**</u>,请确保你使用的是最新的 API 版本。
|
||||
|
||||
#### 字节码类型
|
||||
|
||||
|
Reference in New Issue
Block a user