Fix bug when nameConditions not record to hashCode by findFields, findMethods in ReflectionTool

This commit is contained in:
2022-09-07 23:14:11 +08:00
parent c01d203f6e
commit a1428b3037

View File

@@ -101,7 +101,8 @@ internal object ReflectionTool {
rulesData.name.isBlank() && rulesData.nameConditions == null && rulesData.name.isBlank() && rulesData.nameConditions == null &&
rulesData.modifiers == null && rulesData.type == null rulesData.modifiers == null && rulesData.type == null
) error("You must set a condition when finding a Field") ) error("You must set a condition when finding a Field")
val hashCode = ("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.type}][${rulesData.modifiers}][$classSet]").hashCode() val hashCode = ("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.nameConditions}]" +
"[${rulesData.type}][${rulesData.modifiers}][$classSet]").hashCode()
return ReflectsCacheStore.findFields(hashCode) ?: let { return ReflectsCacheStore.findFields(hashCode) ?: let {
val fields = HashSet<Field>() val fields = HashSet<Field>()
classSet?.declaredFields?.apply { classSet?.declaredFields?.apply {
@@ -220,9 +221,8 @@ internal object ReflectionTool {
rulesData.paramCountRange.isEmpty() && rulesData.paramTypes == null && rulesData.paramCountRange.isEmpty() && rulesData.paramTypes == null &&
rulesData.returnType == null rulesData.returnType == null
) error("You must set a condition when finding a Method") ) error("You must set a condition when finding a Method")
val hashCode = val hashCode = ("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.nameConditions}][${rulesData.paramCount}]" +
("[$orderIndex][$matchIndex][${rulesData.name}][${rulesData.paramCount}][${rulesData.paramTypes.typeOfString()}]" + "[${rulesData.paramTypes.typeOfString()}][${rulesData.returnType}][${rulesData.modifiers}][$classSet]").hashCode()
"[${rulesData.returnType}][${rulesData.modifiers}][$classSet]").hashCode()
return ReflectsCacheStore.findMethods(hashCode) ?: let { return ReflectsCacheStore.findMethods(hashCode) ?: let {
val methods = HashSet<Method>() val methods = HashSet<Method>()
classSet?.declaredMethods?.apply { classSet?.declaredMethods?.apply {