refactor: optimize opt-in annotations

This commit is contained in:
2023-10-04 03:15:50 +08:00
parent 3d149a92ca
commit 89cec45326
7 changed files with 11 additions and 10 deletions

View File

@@ -35,6 +35,7 @@ package com.highcapable.yukihookapi.hook.core
import com.highcapable.yukihookapi.YukiHookAPI
import com.highcapable.yukihookapi.hook.bean.HookClass
import com.highcapable.yukihookapi.hook.core.annotation.DangerousHookOperation
import com.highcapable.yukihookapi.hook.core.annotation.LegacyHookApi
import com.highcapable.yukihookapi.hook.core.api.compat.HookApiCategoryHelper
import com.highcapable.yukihookapi.hook.core.api.helper.YukiHookHelper
import com.highcapable.yukihookapi.hook.core.api.priority.YukiHookPriority
@@ -56,7 +57,6 @@ import com.highcapable.yukihookapi.hook.factory.toJavaPrimitiveType
import com.highcapable.yukihookapi.hook.log.YLog
import com.highcapable.yukihookapi.hook.param.HookParam
import com.highcapable.yukihookapi.hook.param.PackageParam
import com.highcapable.yukihookapi.hook.param.annotation.LegacyHookApi
import com.highcapable.yukihookapi.hook.type.java.AnyClass
import com.highcapable.yukihookapi.hook.type.java.JavaClass
import com.highcapable.yukihookapi.hook.type.java.JavaClassLoader
@@ -167,6 +167,7 @@ class YukiMemberHookCreator internal constructor(private val packageParam: Packa
* @return [Class]
* @throws IllegalStateException 如果当前 [Class] 未被正确装载或为 [HookClass.isPlaceholder]
*/
@LegacyHookApi
val instanceClass
get() = if (hookClass.isPlaceholder)
error("This hook instance is create by Members, not support any hook class instance")

View File

@@ -29,7 +29,7 @@ package com.highcapable.yukihookapi.hook.core.annotation
@RequiresOptIn(message = "允许 Hook 过程中的所有危险行为可能导致意料之外的情况发生", level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Target(AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.BINARY)
/**
* 标记需要 [RequiresOptIn] 的功能

View File

@@ -25,11 +25,11 @@
*
* This file is created by fankes on 2023/10/3.
*/
package com.highcapable.yukihookapi.hook.param.annotation
package com.highcapable.yukihookapi.hook.core.annotation
@RequiresOptIn(message = "这种方式将不再被推荐且将在 2.x.x 版本完全移除,建议迁移到使用 Member 创建 Hook 的新写法", level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Target(AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.BINARY)
/**
* 标记需要 [RequiresOptIn] 的功能

View File

@@ -25,11 +25,11 @@
*
* This file is created by fankes on 2023/10/3.
*/
package com.highcapable.yukihookapi.hook.param.annotation
package com.highcapable.yukihookapi.hook.core.annotation
@RequiresOptIn(message = "Resources Hook 功能将在 2.x.x 版本完全移除 (如果必须使用,你可以继续使用 1.x.x 版本)", level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Target(AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.BINARY)
/**
* 标记需要 [RequiresOptIn] 的功能

View File

@@ -25,7 +25,7 @@
*
* This file is created by fankes on 2022/2/2.
*/
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST")
@file:Suppress("unused", "MemberVisibilityCanBePrivate", "UNCHECKED_CAST", "OPT_IN_USAGE")
package com.highcapable.yukihookapi.hook.param

View File

@@ -43,6 +43,8 @@ import com.highcapable.yukihookapi.hook.bean.HookResources
import com.highcapable.yukihookapi.hook.bean.VariousClass
import com.highcapable.yukihookapi.hook.core.YukiMemberHookCreator
import com.highcapable.yukihookapi.hook.core.YukiResourcesHookCreator
import com.highcapable.yukihookapi.hook.core.annotation.LegacyHookApi
import com.highcapable.yukihookapi.hook.core.annotation.LegacyResourcesHook
import com.highcapable.yukihookapi.hook.core.api.priority.YukiHookPriority
import com.highcapable.yukihookapi.hook.core.finder.base.BaseFinder
import com.highcapable.yukihookapi.hook.core.finder.classes.DexClassFinder
@@ -52,8 +54,6 @@ import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.core.finder.type.factory.ClassConditions
import com.highcapable.yukihookapi.hook.entity.YukiBaseHooker
import com.highcapable.yukihookapi.hook.log.YLog
import com.highcapable.yukihookapi.hook.param.annotation.LegacyHookApi
import com.highcapable.yukihookapi.hook.param.annotation.LegacyResourcesHook
import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper
import com.highcapable.yukihookapi.hook.utils.factory.value
import com.highcapable.yukihookapi.hook.xposed.bridge.YukiXposedModule

View File

@@ -29,7 +29,7 @@ package com.highcapable.yukihookapi.hook.xposed.channel.annotation
@RequiresOptIn(message = "这是一个危险的操作,允许发送过大的数据可能导致宿主或模块崩溃", level = RequiresOptIn.Level.WARNING)
@MustBeDocumented
@Target(AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.BINARY)
/**
* 标记需要 [RequiresOptIn] 的功能