mirror of
https://github.com/HighCapable/YukiHookAPI.git
synced 2025-09-06 02:35:40 +08:00
Fix some bugs
This commit is contained in:
@@ -52,7 +52,7 @@ internal object ReflectionTool {
|
|||||||
* @param modifiers 变量描述
|
* @param modifiers 变量描述
|
||||||
* @param type 变量类型
|
* @param type 变量类型
|
||||||
* @return [Field]
|
* @return [Field]
|
||||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
* @throws IllegalStateException 如果 [classSet] 为 null 或未设置任何条件
|
||||||
* @throws NoSuchFieldError 如果找不到变量
|
* @throws NoSuchFieldError 如果找不到变量
|
||||||
*/
|
*/
|
||||||
internal fun findField(
|
internal fun findField(
|
||||||
@@ -63,11 +63,11 @@ internal object ReflectionTool {
|
|||||||
modifiers: ModifierRules?,
|
modifiers: ModifierRules?,
|
||||||
type: Class<*>?
|
type: Class<*>?
|
||||||
): Field {
|
): Field {
|
||||||
|
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()
|
val hashCode = ("[$orderIndex][$matchIndex][$name][$type][$modifiers][$classSet]").hashCode()
|
||||||
return MemberCacheStore.findField(hashCode) ?: let {
|
return MemberCacheStore.findField(hashCode) ?: let {
|
||||||
var field: Field? = null
|
var field: Field? = null
|
||||||
if (orderIndex == null && matchIndex != null && name.isBlank() && modifiers == null && type == null)
|
|
||||||
error("You must set a condition when finding a Field")
|
|
||||||
classSet?.declaredFields?.apply {
|
classSet?.declaredFields?.apply {
|
||||||
var typeIndex = -1
|
var typeIndex = -1
|
||||||
var nameIndex = -1
|
var nameIndex = -1
|
||||||
@@ -155,7 +155,7 @@ internal object ReflectionTool {
|
|||||||
* @param paramCount 方法参数个数
|
* @param paramCount 方法参数个数
|
||||||
* @param paramTypes 方法参数类型
|
* @param paramTypes 方法参数类型
|
||||||
* @return [Method]
|
* @return [Method]
|
||||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
* @throws IllegalStateException 如果 [classSet] 为 null 或未设置任何条件
|
||||||
* @throws NoSuchMethodError 如果找不到方法
|
* @throws NoSuchMethodError 如果找不到方法
|
||||||
*/
|
*/
|
||||||
internal fun findMethod(
|
internal fun findMethod(
|
||||||
@@ -168,6 +168,8 @@ internal object ReflectionTool {
|
|||||||
paramCount: Int,
|
paramCount: Int,
|
||||||
paramTypes: Array<out Class<*>>?
|
paramTypes: Array<out Class<*>>?
|
||||||
): Method {
|
): Method {
|
||||||
|
if (orderIndex == null && matchIndex == null && name.isBlank() && modifiers == null && paramCount < 0 && paramTypes == null && returnType == null)
|
||||||
|
error("You must set a condition when finding a Method")
|
||||||
val hashCode =
|
val hashCode =
|
||||||
("[$orderIndex][$matchIndex][$name][$paramCount][${paramTypes.typeOfString()}][$returnType][$modifiers][$classSet]").hashCode()
|
("[$orderIndex][$matchIndex][$name][$paramCount][${paramTypes.typeOfString()}][$returnType][$modifiers][$classSet]").hashCode()
|
||||||
return MemberCacheStore.findMethod(hashCode) ?: let {
|
return MemberCacheStore.findMethod(hashCode) ?: let {
|
||||||
@@ -286,7 +288,7 @@ internal object ReflectionTool {
|
|||||||
* @param paramCount 构造方法参数个数
|
* @param paramCount 构造方法参数个数
|
||||||
* @param paramTypes 构造方法参数类型
|
* @param paramTypes 构造方法参数类型
|
||||||
* @return [Constructor]
|
* @return [Constructor]
|
||||||
* @throws IllegalStateException 如果 [classSet] 为 null
|
* @throws IllegalStateException 如果 [classSet] 为 null 或未设置任何条件
|
||||||
* @throws NoSuchMethodError 如果找不到构造方法
|
* @throws NoSuchMethodError 如果找不到构造方法
|
||||||
*/
|
*/
|
||||||
internal fun findConstructor(
|
internal fun findConstructor(
|
||||||
@@ -297,6 +299,8 @@ internal object ReflectionTool {
|
|||||||
paramCount: Int,
|
paramCount: Int,
|
||||||
paramTypes: Array<out Class<*>>?
|
paramTypes: Array<out Class<*>>?
|
||||||
): Constructor<*> {
|
): Constructor<*> {
|
||||||
|
if (orderIndex == null && matchIndex == null && paramCount < 0 && paramTypes == null && modifiers == null)
|
||||||
|
error("You must set a condition when finding a Constructor")
|
||||||
val hashCode = ("[$orderIndex][$matchIndex][$paramCount][${paramTypes.typeOfString()}][$modifiers][$classSet]").hashCode()
|
val hashCode = ("[$orderIndex][$matchIndex][$paramCount][${paramTypes.typeOfString()}][$modifiers][$classSet]").hashCode()
|
||||||
return MemberCacheStore.findConstructor(hashCode) ?: let {
|
return MemberCacheStore.findConstructor(hashCode) ?: let {
|
||||||
var constructor: Constructor<*>? = null
|
var constructor: Constructor<*>? = null
|
||||||
|
Reference in New Issue
Block a user