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>
@ -781,7 +796,7 @@ public class ClassUtil {
/**
* 按广度优先遍历包括{@code root}在内其层级结构中的所有类和接口直到{@code terminator}返回{@code false}
*
* @param root 根类
* @param root 根类
* @param terminator 对遍历到的每个类与接口执行的校验若为{@code false}则立刻中断遍历
*/
public static void traverseTypeHierarchyWhile(
@ -792,8 +807,8 @@ public class ClassUtil {
/**
* 按广度优先遍历包括{@code root}在内其层级结构中的所有类和接口直到{@code terminator}返回{@code false}
*
* @param root 根类
* @param filter 过滤器被过滤的类及其层级结构中的类与接口将被忽略
* @param root 根类
* @param filter 过滤器被过滤的类及其层级结构中的类与接口将被忽略
* @param terminator 对遍历到的每个类与接口执行的校验若为{@code false}则立刻中断遍历
*/
public static void traverseTypeHierarchyWhile(
@ -812,9 +827,9 @@ public class ClassUtil {
* <li>{@code type}距离相同的接口则顺序遵循接口在{@link Class#getInterfaces()}的顺序</li>
* </ul>
*
* @param root 根类
* @param filter 过滤器被过滤的类及其层级结构中的类与接口将被忽略
* @param consumer 对遍历到的每个类与接口执行的操作每个类和接口都只会被访问一次
* @param root 根类
* @param filter 过滤器被过滤的类及其层级结构中的类与接口将被忽略
* @param consumer 对遍历到的每个类与接口执行的操作每个类和接口都只会被访问一次
* @param includeRoot 是否包括根类
*/
public static void traverseTypeHierarchy(