[gogo][jline] Make sure static methods are ignored when considering functional interfaces
@@ -27,6 +27,7 @@ import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collections;
@@ -106,7 +107,7 @@ public class BaseConverters implements Converter {
}
int nb = 0;
for (Method method : clazz.getMethods()) {
- if (method.isDefault() || isObjectMethod(method)) {
+ if (method.isDefault() || isObjectMethod(method) || isStatic(method)) {
continue;
}
nb++;
@@ -114,6 +115,10 @@ public class BaseConverters implements Converter {
return nb == 1;
}
+ public static boolean isStatic(Method method) {
+ return (method.getModifiers() & Modifier.STATIC) == Modifier.STATIC;
+ }
+
public static boolean isObjectMethod(Method method) {
switch (method.getName()) {
case "toString":
