This commit is contained in:
Looly 2023-03-12 13:28:08 +08:00
parent d9f6de720a
commit 3a259cdb58
2 changed files with 12 additions and 2 deletions

View File

@ -116,8 +116,11 @@ public class BeanUtil {
if (ClassUtil.isNormalClass(clazz)) {
for (final Method method : clazz.getMethods()) {
if (method.getParameterCount() == 0) {
if (method.getName().startsWith("get") || method.getName().startsWith("is")) {
return true;
final String name = method.getName();
if (name.startsWith("get") || name.startsWith("is")) {
if(false == "getClass".equals(name)){
return true;
}
}
}
}

View File

@ -892,4 +892,11 @@ public class BeanUtilTest {
}, copyOptions);
Assert.assertEquals("123", pojo.getName());
}
@Test
public void hasGetterTest() {
// https://gitee.com/dromara/hutool/issues/I6M7Z7
final boolean b = BeanUtil.hasGetter(Object.class);
Assert.assertFalse(b);
}
}