This commit is contained in:
Looly 2024-03-07 12:46:02 +08:00
parent fbb97f0c9a
commit 27d67c4d84
2 changed files with 11 additions and 4 deletions

View File

@ -166,8 +166,12 @@ public class PropDesc {
*/ */
public Object getValue(final Object bean) { public Object getValue(final Object bean) {
if (null != this.getter) { if (null != this.getter) {
//return MethodUtil.invoke(bean, this.getter); try{
return LambdaUtil.buildGetter(this.getter).apply(bean); return LambdaUtil.buildGetter(this.getter).apply(bean);
} catch (final Exception ignore){
// issue#I96JIP在jdk14+多模块项目中存在权限问题使用传统反射
return MethodUtil.invoke(bean, this.getter);
}
} else if (ModifierUtil.isPublic(this.field)) { } else if (ModifierUtil.isPublic(this.field)) {
return FieldUtil.getFieldValue(bean, this.field); return FieldUtil.getFieldValue(bean, this.field);
} }

View File

@ -28,9 +28,8 @@ import java.util.Map;
/** /**
* 以类似反射的方式动态创建Lambda在性能上有一定优势同时避免每次调用Lambda时创建匿名内部类 * 以类似反射的方式动态创建Lambda在性能上有一定优势同时避免每次调用Lambda时创建匿名内部类
* TODO JDK9+存在兼容问题当参数为原始类型时报错
* *
* @author nasodaengineer * @author nasodaengineer
*/ */
public class LambdaFactory { public class LambdaFactory {
@ -108,6 +107,10 @@ public class LambdaFactory {
/** /**
* 通过Lambda函数代理方法或构造 * 通过Lambda函数代理方法或构造
* <p>
* TODO 在多模块项目中使用module-info.java声明的模块项目使用此方法获取的Lookup对象存在权限不足问题<br>
* https://gitee.com/dromara/hutool/issues/I96JIP
* </p>
* *
* @param funcType 函数类型 * @param funcType 函数类型
* @param funcMethod 函数执行的方法 * @param funcMethod 函数执行的方法