From e108aa18ce2ee072b92d0af02026354e877d235b Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 29 Oct 2024 19:42:56 +0800 Subject: [PATCH] =?UTF-8?q?PropDesc.isTransientForGet=E4=BD=BF=E7=94=A8cla?= =?UTF-8?q?ssName=EF=BC=8C=E9=81=BF=E5=85=8DAndroid=E4=B8=8B=E7=B1=BB?= =?UTF-8?q?=E6=89=BE=E4=B8=8D=E5=88=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/core/bean/PropDesc.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e45aea39..cef651bd2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.33(2024-10-25) +# 5.8.33(2024-10-29) ### 🐣新特性 * 【core 】 SyncFinisher增加setExecutorService方法(issue#IANKQ1@Gitee) @@ -16,6 +16,7 @@ * 【db 】 QrCodeUtil添加二维码logo支持配置圆角(pr#3747@Github) * 【core 】 TreeUtil.buildSingle指定rootId节点存在时,作为根节点(issue#IAUSHR@Gitee) * 【core 】 EscapeUtil.escapeHtml4增加空处理(issue#IAZMYU@Gitee) +* 【core 】 PropDesc.isTransientForGet使用className,避免Android下类找不到问题(issue#IB0JP5@Gitee) ### 🐞Bug修复 * 【json 】 修复JSONConfig.setDateFormat设置后toBean无效问题(issue#3713@Github) diff --git a/hutool-core/src/main/java/cn/hutool/core/bean/PropDesc.java b/hutool-core/src/main/java/cn/hutool/core/bean/PropDesc.java index af0d9edef..460422a59 100644 --- a/hutool-core/src/main/java/cn/hutool/core/bean/PropDesc.java +++ b/hutool-core/src/main/java/cn/hutool/core/bean/PropDesc.java @@ -363,6 +363,7 @@ public class PropDesc { * @return 是否为Transient关键字修饰的 * @since 5.3.11 */ + @SuppressWarnings({"rawtypes", "unchecked"}) private boolean isTransientForGet() { boolean isTransient = ModifierUtil.hasModifier(this.field, ModifierUtil.ModifierType.TRANSIENT); @@ -372,7 +373,17 @@ public class PropDesc { // 检查注解 if (false == isTransient) { - isTransient = AnnotationUtil.hasAnnotation(this.getter, Transient.class); + //isTransient = AnnotationUtil.hasAnnotation(this.getter, Transient.class); + Class aClass = null; + try { + // issue#IB0JP5,Android可能无这个类 + aClass = Class.forName("java.beans.Transient"); + } catch (final ClassNotFoundException e) { + // ignore + } + if(null != aClass){ + isTransient = AnnotationUtil.hasAnnotation(this.getter, aClass); + } } }