You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "mercyblitz (GitHub)" <gi...@apache.org> on 2020/01/16 06:58:13 UTC
[GitHub] [dubbo] mercyblitz opened issue #5664: [Defect] About
static methods in MethodUtils
There is some defect in the above two methods:
```java
static boolean isSetter(Method method) {
return method.getName().startsWith("set")
&& !"set".equals(method.getName())
&& Modifier.isPublic(method.getModifiers())
&& method.getParameterCount() == 1
&& ClassUtils.isPrimitive(method.getParameterTypes()[0]);
}
static boolean isGetter(Method method) {
String name = method.getName();
return (name.startsWith("get") || name.startsWith("is"))
&& !"get".equals(name) && !"is".equals(name)
&& !"getClass".equals(name) && !"getObject".equals(name)
&& Modifier.isPublic(method.getModifiers())
&& method.getParameterTypes().length == 0
&& ClassUtils.isPrimitive(method.getReturnType());
}
static boolean isMetaMethod(Method method) {
String name = method.getName();
if (!(name.startsWith("get") || name.startsWith("is"))) {
return false;
}
if ("get".equals(name)) {
return false;
}
if ("getClass".equals(name)) {
return false;
}
if (!Modifier.isPublic(method.getModifiers())) {
return false;
}
if (method.getParameterTypes().length != 0) {
return false;
}
if (!ClassUtils.isPrimitive(method.getReturnType())) {
return false;
}
return true;
}
```
- The parameter type or return type should not only primitive
[ Full content available at: https://github.com/apache/dubbo/issues/5664 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org