fix: fix and close #I9V10O

This commit is contained in:
林钟一六 2024-06-04 22:15:20 +08:00
parent d111744080
commit 6c1764f1e6

View File

@ -285,23 +285,11 @@ public class ClassUtil {
} }
Method[] declaredMethods = clazz.getDeclaredMethods(); Method[] declaredMethods = clazz.getDeclaredMethods();
if (clazz.isInterface()) { for (Method method : declaredMethods) {
for (Method method : declaredMethods) { if (predicate == null || predicate.test(method)) {
// 接口类只需要获取 default 方法 methods.add(method);
if (method.isDefault() && (predicate == null || predicate.test(method))) { if (firstOnly) {
methods.add(method); break;
if (firstOnly) {
break;
}
}
}
} else {
for (Method method : declaredMethods) {
if (predicate == null || predicate.test(method)) {
methods.add(method);
if (firstOnly) {
break;
}
} }
} }
} }