Fix Java "void" Type Class not found problem in Android 7.0 (API 24) or latest

This commit is contained in:
2022-12-30 01:25:11 +08:00
parent bea96f8670
commit 1fb4ca6bcf
2 changed files with 12 additions and 11 deletions

View File

@@ -40,6 +40,7 @@ import com.highcapable.yukihookapi.hook.core.finder.members.MethodFinder
import com.highcapable.yukihookapi.hook.core.finder.tools.ReflectionTool
import com.highcapable.yukihookapi.hook.core.finder.type.factory.*
import com.highcapable.yukihookapi.hook.type.java.AnyClass
import com.highcapable.yukihookapi.hook.type.java.UnitType
import com.highcapable.yukihookapi.hook.xposed.bridge.status.YukiHookModuleStatus
import com.highcapable.yukihookapi.hook.xposed.parasitic.AppParasitics
import dalvik.system.BaseDexClassLoader
@@ -180,9 +181,8 @@ infix fun Class<*>?.notImplements(other: Class<*>?) = implements(other).not()
* @return [Class]
*/
fun Class<*>.toJavaPrimitiveType() =
(name.replace(Unit.toString(), "void")
.replace("java.lang.Void", "void")
.replace("java.lang.Boolean", "boolean")
if (name != Unit.toString() && name != "java.lang.Void" && name != "void")
(name.replace("java.lang.Boolean", "boolean")
.replace("java.lang.Integer", "int")
.replace("java.lang.Float", "float")
.replace("java.lang.Double", "double")
@@ -190,6 +190,7 @@ fun Class<*>.toJavaPrimitiveType() =
.replace("java.lang.Short", "short")
.replace("java.lang.Character", "char")
.replace("java.lang.Byte", "byte")).toClass()
else UnitType
/**
* 通过字符串类名转换为 [loader] 中的实体类

View File

@@ -148,7 +148,7 @@ val DoubleType get() = "double".toClass()
* 这是 Java 原始类型 (Primitive Type) - 它在字节码中的关键字为 "void"
* @return [Class]
*/
val UnitType get() = "void".toClass()
val UnitType get() = Void.TYPE ?: "void".toClass()
/**
* 获得 [Any] 类型