findField
按查询条件查找字段。
val f = findField(clz) {
name("mCallback")
type(Runnable::class.java)
}Content copied to clipboard
Return
第一个匹配的 Field(已 setAccessible)
Parameters
clz
目标类
findSuper
null=智能搜索(默认), false=仅当前类, true=强制搜索继承链
query
查询条件块
Throws
fun findField(className: String, classLoader: ClassLoader = EzReflect.classLoader, findSuper: Boolean? = null, query: FieldQuery.() -> Unit): Field
按类名查找字段。
Parameters
className
目标类名
classLoader
用于加载目标类的 ClassLoader
findSuper
null=智能搜索(默认), false=仅当前类, true=强制搜索继承链
query
查询条件块
fun String.findField(classLoader: ClassLoader = EzReflect.classLoader, findSuper: Boolean? = null, query: FieldQuery.() -> Unit): Field
从类名直接查找字段的便捷写法,等价于 loadClass(name).findField { ... }。 适合一次性查找场景;多次操作同一个类时推荐先显式 loadClass / loadClassFirst。
val f = "com.example.Target".findField { name("mValue") }Content copied to clipboard
Parameters
classLoader
用于加载当前类名的 ClassLoader
findSuper
null=智能搜索(默认), false=仅当前类, true=强制搜索继承链
query
查询条件块
从 Class 对象直接查找字段。
val f = clz.findField {
name("mCallback")
type(Runnable::class.java)
}Content copied to clipboard
Parameters
findSuper
null=智能搜索(默认), false=仅当前类, true=强制搜索继承链
query
查询条件块