Skip to content

Commit

Permalink
docs: update api-exception, example
Browse files Browse the repository at this point in the history
  • Loading branch information
fankes committed Oct 7, 2023
1 parent 94ffac8 commit 8462d9c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 124 deletions.
58 changes: 0 additions & 58 deletions docs-source/src/en/config/api-exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -1080,48 +1080,6 @@ Please make sure you have loaded the `encase` method of `YukiHookAPI` in the cor

###### exception

::: danger UnsupportedOperationException

!!!DANGEROUS!!! Hook \[**CLASS**\] Class is a dangerous behavior! \[**CONTENT**\] \[**SOLVE**\]

:::

**Abnormal**

You tried to hook a `Class` object in the list of dangerous behaviors, such as `Class`, `ClassLoader`, `Method`.

> The following example
```kotlin
// <Scenario 1>
JavaClassLoader.hook {
// ...
}
// <Scenario 2>
JavaClass.hook {
// ...
}
// <Scenario 3>
JavaMethod.hook {
// ...
}
// ...
```

**Solution**

These functions are internal to the system, <u>**they should not be hooked, may not be supported on some Hook Frameworks, and may cause other errors**</u>, please try to replace the hook point.

::: tip

If you still want to use this feature, please refer to [YukiMemberHookCreator.useDangerousOperation](../api/public/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator#usedangerousoperation-method) method.

But **It is strongly recommended not to do this, please do not report any problems, <u>all the consequences will be borne by yourself</u>**.

:::

###### exception

::: danger NoClassDefFoundError

Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiHookAPI#ReflectionTool
Expand Down Expand Up @@ -1847,22 +1805,6 @@ For details, please refer to [Status Monitor](../guide/example#status-monitor).

::: danger IllegalStateException

This hook instance is create by Members, not support any hook class instance

:::

**Abnormal**

Hook instance is created using `Member.hook { ... }` instead of `Class.hook { ... }` and uses `instanceClass`.

**Solution**

You can only use `instanceClass` if you created a Hook instance using `Class.hook { ... }`.

###### exception

::: danger IllegalStateException

Use of searchClass { ... }.hook { ... } is an error, please use like searchClass { ... }.get()?.hook { ... }

:::
Expand Down
8 changes: 4 additions & 4 deletions docs-source/src/en/guide/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ TargetClass.hook {
method {
// Your code here.
}
before {
beforeHook {
// Your code here.
}
after {
afterHook {
// Your code here.
}
}
Expand Down Expand Up @@ -463,7 +463,7 @@ injectMember {
method {
throw RuntimeException("Exception Test")
}
after {
afterHook {
// ...
}
}.result {
Expand All @@ -475,7 +475,7 @@ injectMember {
method {
// ...
}
after {
afterHook {
throw RuntimeException("Exception Test")
}
}.result {
Expand Down
58 changes: 0 additions & 58 deletions docs-source/src/zh-cn/config/api-exception.md
Original file line number Diff line number Diff line change
Expand Up @@ -1017,48 +1017,6 @@ YukiHookAPI cannot support current Hook API or cannot found any available Hook A

###### exception

::: danger UnsupportedOperationException

!!!DANGEROUS!!! Hook \[**CLASS**\] Class is a dangerous behavior! \[**CONTENT**\] \[**SOLVE**\]

:::

**异常原因**

你尝试 Hook 了处于危险行为列表中的 `Class` 对象,例如 `Class``ClassLoader``Method`

> 示例如下
```kotlin
// <情景1>
JavaClassLoader.hook {
// ...
}
// <情景2>
JavaClass.hook {
// ...
}
// <情景3>
JavaMethod.hook {
// ...
}
// ...
```

**解决方案**

这些功能是系统内部的,<u>**它们不应该被 Hook,在部分 Hook Framework 上可能不被支持,还会引发其它错误**</u>,请尝试更换 Hook 点。

::: tip

若你仍要使用此功能,请参考 [YukiMemberHookCreator.useDangerousOperation](../api/public/com/highcapable/yukihookapi/hook/core/YukiMemberHookCreator#usedangerousoperation-method) 方法。

但是**强烈建议不要这样做,发生问题请不要反馈,<u>自行承担一切后果</u>**

:::

###### exception

::: danger NoClassDefFoundError

Can't find this Class in \[**CLASSLOADER**\]: **CONTENT** Generated by YukiHookAPI#ReflectionTool
Expand Down Expand Up @@ -1765,22 +1723,6 @@ TargetClass.hook {

::: danger IllegalStateException

This hook instance is create by Members, not support any hook class instance

:::

**异常原因**

使用 `Member.hook { ... }` 并非 `Class.hook { ... }` 创建了 Hook 实例并使用了 `instanceClass`

**解决方案**

你只能在使用 `Class.hook { ... }` 创建 Hook 实例的情况下使用 `instanceClass`

###### exception

::: danger IllegalStateException

Use of searchClass { ... }.hook { ... } is an error, please use like searchClass { ... }.get()?.hook { ... }

:::
Expand Down
8 changes: 4 additions & 4 deletions docs-source/src/zh-cn/guide/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ TargetClass.hook {
method {
// Your code here.
}
before {
beforeHook {
// Your code here.
}
after {
afterHook {
// Your code here.
}
}
Expand Down Expand Up @@ -463,7 +463,7 @@ injectMember {
method {
throw RuntimeException("Exception Test")
}
after {
afterHook {
// ...
}
}.result {
Expand All @@ -475,7 +475,7 @@ injectMember {
method {
// ...
}
after {
afterHook {
throw RuntimeException("Exception Test")
}
}.result {
Expand Down

0 comments on commit 8462d9c

Please sign in to comment.