You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2017/03/08 16:04:58 UTC
svn commit: r1785993 -
/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java
Author: gnodet
Date: Wed Mar 8 16:04:58 2017
New Revision: 1785993
URL: http://svn.apache.org/viewvc?rev=1785993&view=rev
Log:
[FELIX-5463] [gogo][jline] Make sure static methods are ignored when considering functional interfaces
Modified:
felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java
Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java?rev=1785993&r1=1785992&r2=1785993&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java (original)
+++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/BaseConverters.java Wed Mar 8 16:04:58 2017
@@ -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 C
}
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 C
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":