Skip to content

Commit 431edd3

Browse files
fix: Exclude abstract methods from proxy matching (#1937)
1 parent 28adafa commit 431edd3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/io/appium/java_client/pagefactory/utils/ProxyFactory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.appium.java_client.proxy.MethodCallListener;
2020
import net.bytebuddy.description.method.MethodDescription;
2121
import net.bytebuddy.matcher.ElementMatcher;
22-
import net.bytebuddy.matcher.ElementMatchers;
2322

2423
import java.util.Arrays;
2524
import java.util.Collections;
@@ -28,7 +27,9 @@
2827

2928
import static io.appium.java_client.proxy.Helpers.OBJECT_METHOD_NAMES;
3029
import static io.appium.java_client.proxy.Helpers.createProxy;
30+
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
3131
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
32+
import static net.bytebuddy.matcher.ElementMatchers.not;
3233

3334
/**
3435
* Original class is a super class of a
@@ -77,9 +78,11 @@ public static <T> T getEnhancedProxy(Class<T> requiredClazz, MethodCallListener
7778
public static <T> T getEnhancedProxy(
7879
Class<T> cls, Class<?>[] params, Object[] values, MethodCallListener listener
7980
) {
80-
ElementMatcher<MethodDescription> extraMatcher = ElementMatchers.not(namedOneOf(
81-
NON_PROXYABLE_METHODS.toArray(new String[0])
82-
));
81+
ElementMatcher<MethodDescription> extraMatcher = not(
82+
namedOneOf(NON_PROXYABLE_METHODS.toArray(new String[0]))
83+
).and(
84+
not(isAbstract())
85+
);
8386
return createProxy(
8487
cls,
8588
values,

0 commit comments

Comments
 (0)