ReflectScope

绑定指定 classLoader 的反射 DSL 作用域。

适合在局部代码块中集中使用 loadClassfindMethod 等 API,避免大量顶层函数直接暴露在当前作用域。

Parameters

classLoader

当前作用域内所有查找 API 默认使用的 ClassLoader

Properties

Link copied to clipboard

当前作用域绑定的默认 ClassLoader

Functions

Link copied to clipboard

在当前作用域的 classLoader 上查找全部构造器。

在当前作用域的 classLoader 上按查询条件查找所有匹配的构造器。

Link copied to clipboard
fun String.findAllFields(findSuper: Boolean? = null): List<Field>

在当前作用域的 classLoader 上查找全部字段。

fun String.findAllFields(findSuper: Boolean? = null, query: FieldQuery.() -> Unit): List<Field>

在当前作用域的 classLoader 上按查询条件查找所有匹配的字段。

Link copied to clipboard
fun String.findAllMethods(findSuper: Boolean? = null): List<Method>

在当前作用域的 classLoader 上查找全部方法。

fun String.findAllMethods(findSuper: Boolean? = null, query: MethodQuery.() -> Unit): List<Method>

在当前作用域的 classLoader 上按查询条件查找所有匹配的方法。

Link copied to clipboard
@JvmName(name = "findClassFromString")
fun String.findClass(): Class<*>

在当前作用域的 classLoader 上按类名查找 Class

fun findClass(name: String): Class<*>

在当前作用域的 classLoader 上查找类,找不到时抛异常。

Link copied to clipboard
@JvmName(name = "findClassOrNullFromString")
fun String.findClassOrNull(): Class<*>?

在当前作用域的 classLoader 上按类名查找 Class,失败返回 null

fun findClassOrNull(name: String): Class<*>?

在当前作用域的 classLoader 上查找类,找不到时返回 null

Link copied to clipboard

在当前作用域的 classLoader 上按查询条件查找构造器。

Link copied to clipboard

在当前作用域的 classLoader 上按查询条件查找构造器,找不到返回 null

Link copied to clipboard
fun String.findField(findSuper: Boolean? = null, query: FieldQuery.() -> Unit): Field

在当前作用域的 classLoader 上按查询条件查找字段。

Link copied to clipboard
fun String.findFieldOrNull(findSuper: Boolean? = null, query: FieldQuery.() -> Unit): Field?

在当前作用域的 classLoader 上按查询条件查找字段,找不到返回 null

Link copied to clipboard
fun findFirstClass(vararg names: String): Class<*>

按多个候选类名依次查找,返回第一个成功的类。

Link copied to clipboard
fun findFirstClassOrNull(vararg names: String): Class<*>?

按多个候选类名依次查找,全部失败时返回 null

Link copied to clipboard
fun String.findMethod(findSuper: Boolean? = null, query: MethodQuery.() -> Unit): Method

在当前作用域的 classLoader 上按查询条件查找方法。

Link copied to clipboard
fun String.findMethodOrNull(findSuper: Boolean? = null, query: MethodQuery.() -> Unit): Method?

在当前作用域的 classLoader 上按查询条件查找方法,找不到返回 null

Link copied to clipboard

通过 Dex/Smali 签名解析并获取字段。

Link copied to clipboard

通过 Dex/Smali 签名解析并获取字段,找不到返回 null

Link copied to clipboard

通过 Dex/Smali 签名解析并获取方法。

Link copied to clipboard

通过 Dex/Smali 签名解析并获取方法,找不到返回 null

Link copied to clipboard
fun loadClass(name: String): Class<*>

在当前作用域的 classLoader 上加载类,找不到时抛异常。

Link copied to clipboard
fun loadClassFirst(vararg names: String): Class<*>

按多个候选类名依次尝试加载,返回第一个成功的类。

Link copied to clipboard
fun loadClassFirstOrNull(vararg names: String): Class<*>?

按多个候选类名依次尝试加载,全部失败时返回 null

Link copied to clipboard
fun loadClassOrNull(name: String): Class<*>?

在当前作用域的 classLoader 上加载类,找不到时返回 null

Link copied to clipboard
fun newInstance(className: String, args: Args = args(), argTypes: ArgTypes = argTypes()): Any

在当前作用域的 classLoader 上按类名创建实例。

Link copied to clipboard
fun String.toClass(): Class<*>

在当前作用域的 classLoader 上把类名字符串解析为 Class

Link copied to clipboard

在当前作用域的 classLoader 上把类名字符串解析为 Class,失败返回 null