diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt index f615f302..2742692e 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/YukiHookAPI.kt @@ -46,7 +46,7 @@ import com.highcapable.yukihookapi.hook.log.* import com.highcapable.yukihookapi.hook.param.PackageParam import com.highcapable.yukihookapi.hook.param.type.HookEntryType import com.highcapable.yukihookapi.hook.param.wrapper.PackageParamWrapper -import com.highcapable.yukihookapi.hook.store.MemberCacheStore +import com.highcapable.yukihookapi.hook.store.ReflectsCacheStore import com.highcapable.yukihookapi.hook.xposed.application.ModuleApplication import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiHookModuleStatus @@ -255,7 +255,7 @@ object YukiHookAPI { * * 启用后会缓存已经找到的 [Class]、[Method]、[Constructor]、[Field] * - * 缓存的 [Member] 都将处于 [MemberCacheStore] 的全局静态实例中 + * 缓存的 [Member] 都将处于 [ReflectsCacheStore] 的全局静态实例中 * * 推荐使用 [MethodFinder]、[ConstructorFinder]、[FieldFinder] 来获取 [Member] * diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt index 8eb6bf63..d08ef629 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/core/reflex/tools/ReflectionTool.kt @@ -30,7 +30,7 @@ package com.highcapable.yukihookapi.hook.core.reflex.tools import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules import com.highcapable.yukihookapi.hook.core.finder.type.NameConditions import com.highcapable.yukihookapi.hook.factory.hasExtends -import com.highcapable.yukihookapi.hook.store.MemberCacheStore +import com.highcapable.yukihookapi.hook.store.ReflectsCacheStore import com.highcapable.yukihookapi.hook.type.defined.UndefinedType import java.lang.reflect.Constructor import java.lang.reflect.Field @@ -74,7 +74,7 @@ internal object ReflectionTool { if (orderIndex == null && matchIndex == null && name.isBlank() && modifiers == null && type == null) error("You must set a condition when finding a Field") val hashCode = ("[$orderIndex][$matchIndex][$name][$type][$modifiers][$classSet]").hashCode() - return MemberCacheStore.findFields(hashCode) ?: let { + return ReflectsCacheStore.findFields(hashCode) ?: let { val fields = HashSet() classSet?.declaredFields?.apply { var typeIndex = -1 @@ -135,7 +135,7 @@ internal object ReflectionTool { if (conditions && isMatched) fields.add(it.apply { isAccessible = true }) } } ?: error("Can't find this Field [$name] because classSet is null") - fields.takeIf { it.isNotEmpty() }?.also { MemberCacheStore.putFields(hashCode, fields) } + fields.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putFields(hashCode, fields) } ?: if (isFindInSuperClass && classSet.hasExtends) findFields( classSet.superclass, @@ -208,7 +208,7 @@ internal object ReflectionTool { ) error("You must set a condition when finding a Method") val hashCode = ("[$orderIndex][$matchIndex][$name][$paramCount][${paramTypes.typeOfString()}][$returnType][$modifiers][$classSet]").hashCode() - return MemberCacheStore.findMethods(hashCode) ?: let { + return ReflectsCacheStore.findMethods(hashCode) ?: let { val methods = HashSet() classSet?.declaredMethods?.apply { var returnTypeIndex = -1 @@ -309,7 +309,7 @@ internal object ReflectionTool { if (conditions && isMatched) methods.add(it.apply { isAccessible = true }) } } ?: error("Can't find this Method [$name] because classSet is null") - methods.takeIf { it.isNotEmpty() }?.also { MemberCacheStore.putMethods(hashCode, methods) } + methods.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putMethods(hashCode, methods) } ?: if (isFindInSuperClass && classSet.hasExtends) findMethods( classSet.superclass, @@ -377,7 +377,7 @@ internal object ReflectionTool { paramCountRange.isEmpty() && paramTypes == null ) error("You must set a condition when finding a Constructor") val hashCode = ("[$orderIndex][$matchIndex][$paramCount][${paramTypes.typeOfString()}][$modifiers][$classSet]").hashCode() - return MemberCacheStore.findConstructors(hashCode) ?: let { + return ReflectsCacheStore.findConstructors(hashCode) ?: let { val constructors = HashSet>() classSet?.declaredConstructors?.apply { var paramTypeIndex = -1 @@ -441,7 +441,7 @@ internal object ReflectionTool { if (conditions && isMatched) constructors.add(it.apply { isAccessible = true }) } } ?: error("Can't find this Constructor because classSet is null") - return constructors.takeIf { it.isNotEmpty() }?.also { MemberCacheStore.putConstructors(hashCode, constructors) } + return constructors.takeIf { it.isNotEmpty() }?.also { ReflectsCacheStore.putConstructors(hashCode, constructors) } ?: if (isFindInSuperClass && classSet.hasExtends) findConstructors( classSet.superclass, diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt index 9255a4c8..865f00e6 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/factory/ReflectionFactory.kt @@ -35,7 +35,7 @@ import com.highcapable.yukihookapi.hook.core.finder.members.ConstructorFinder import com.highcapable.yukihookapi.hook.core.finder.members.FieldFinder import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder import com.highcapable.yukihookapi.hook.core.finder.type.ModifierRules -import com.highcapable.yukihookapi.hook.store.MemberCacheStore +import com.highcapable.yukihookapi.hook.store.ReflectsCacheStore import com.highcapable.yukihookapi.hook.xposed.bridge.YukiHookBridge import com.highcapable.yukihookapi.hook.xposed.bridge.factory.YukiHookHelper import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiHookModuleStatus @@ -82,7 +82,7 @@ val Class<*>.hasExtends get() = superclass.name != "java.lang.Object" */ fun classOf(name: String, loader: ClassLoader? = null): Class<*> { val hashCode = ("[$name][$loader]").hashCode() - return MemberCacheStore.findClass(hashCode) ?: run { + return ReflectsCacheStore.findClass(hashCode) ?: run { when { YukiHookBridge.hasXposedBridge -> runCatching { YukiHookHelper.findClass(name, loader) }.getOrNull() @@ -92,7 +92,7 @@ fun classOf(name: String, loader: ClassLoader? = null): Class<*> { } loader == null -> Class.forName(name) else -> loader.loadClass(name) - }.also { MemberCacheStore.putClass(hashCode, it) } + }.also { ReflectsCacheStore.putClass(hashCode, it) } } } diff --git a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/MemberCacheStore.kt b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/ReflectsCacheStore.kt similarity index 93% rename from yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/MemberCacheStore.kt rename to yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/ReflectsCacheStore.kt index 7617e85d..8ef216f9 100644 --- a/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/MemberCacheStore.kt +++ b/yukihookapi/src/api/kotlin/com/highcapable/yukihookapi/hook/store/ReflectsCacheStore.kt @@ -34,13 +34,13 @@ import java.lang.reflect.Member import java.lang.reflect.Method /** - * 这是一个全局静态的 [Member] 缓存实例 + * 这是一个全局静态的 [Class]、[Member] 缓存实例 * - * 为防止 [Member] 复用过高造成的系统 GC 问题 + * 为防止 [Class]、[Member] 复用过高造成的系统 GC 问题 * - * 查询后的 [Member] 在 [YukiHookAPI.Configs.isEnableMemberCache] 启用后自动进入缓存 + * 查询后的 [Class]、[Member] 在 [YukiHookAPI.Configs.isEnableMemberCache] 启用后自动进入缓存 */ -internal object MemberCacheStore { +internal object ReflectsCacheStore { /** 缓存的 [Class] */ private val classData = HashMap?>()