This commit is contained in:
Looly 2024-10-29 18:09:01 +08:00
parent 045de55b5c
commit 2b0dee29fa
2 changed files with 29 additions and 7 deletions

View File

@ -432,6 +432,7 @@ public class PropDesc {
* @param getterMethod 读取方法可为{@code null}
* @return 是否为Transient关键字修饰的
*/
@SuppressWarnings({"rawtypes", "unchecked"})
private static boolean isTransientForGet(final Field field, final Method getterMethod) {
boolean isTransient = ModifierUtil.hasAny(field, ModifierType.TRANSIENT);
@ -441,7 +442,13 @@ public class PropDesc {
// 检查注解
if (!isTransient) {
isTransient = AnnotationUtil.hasAnnotation(getterMethod, Transient.class);
try {
// issue#IB0JP5Android可能无这个类
final Class aClass = Class.forName("java.beans.Transient");
isTransient = AnnotationUtil.hasAnnotation(getterMethod, aClass);
} catch (final ClassNotFoundException e) {
// ignore
}
}
}

View File

@ -710,6 +710,21 @@ public class ClassUtil {
return location.getPath();
}
/**
* 判断指定类名的类是否存在
*
* @param className 全类名
* @param loader {@link ClassLoader}
* @return 类名的类是否存在
*/
public static boolean isClassExists(final String className, final ClassLoader loader) {
try {
return null != forName(className, false, loader);
} catch (final Exception e) {
return false;
}
}
/**
* 加载指定名称的类支持
* <ul>